Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to put information (name, value) in a point, this is my property definition

MgClassDefinition classDefinition = new MgClassDefinition();
classDefinition.SetName("Points");
classDefinition.SetDescription("Feature class with point data.");
classDefinition.SetDefaultGeometryPropertyName("GEOM");

MgPropertyDefinitionCollection idProps = classDefinition.GetIdentityProperties();
MgPropertyDefinitionCollection clsProps = classDefinition.GetProperties();

// Create an identify property
MgDataPropertyDefinition identityProperty = new MgDataPropertyDefinition("KEY");
identityProperty.SetDataType(MgPropertyType.Int32);
identityProperty.SetAutoGeneration(true);
identityProperty.SetReadOnly(true);

    clsProps.Add(identityProperty);
    idProps.Add(identityProperty);

// name
MgDataPropertyDefinition nameProperty = new MgDataPropertyDefinition("NAME");
nameProperty.SetDataType(MgPropertyType.String);
// Add the name property to the class definition
clsProps.Add(nameProperty);

// geometry property
MgGeometricPropertyDefinition geometryProperty = new MgGeometricPropertyDefinition("GEOM");
geometryProperty.SetGeometryTypes(MgFeatureGeometricType.Point);
// Add the geometry property to the class definition
clsProps.Add(geometryProperty);

// Create a feature schema
MgFeatureSchema featureSchema = new MgFeatureSchema("PointSchema", "Point schema");
MgClassDefinitionCollection classes = featureSchema.GetClasses();
// Add the feature schema to the class definition
classes.Add(classDefinition);

// Create the feature source
String featureSourceName = "Session:" + sessionId + "//prueba1_Buffer.FeatureSource";
MgResourceIdentifier resourceIdentifier = new MgResourceIdentifier(featureSourceName);
//wkt = "LOCALCS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
String wkt = "GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]";
MgCreateSdfParams sdfParams = new MgCreateSdfParams("LatLong", wkt, featureSchema);
featureService.CreateFeatureSource(resourceIdentifier, sdfParams);

I use a method MakePoint to add a new point feature

MgPropertyCollection MakePoint(String name, double x, double y)
{
    MgPropertyCollection propertyCollection = new MgPropertyCollection();

    MgStringProperty nameProperty = new MgStringProperty("NAME", name);
    propertyCollection.Add(nameProperty);

    MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
    MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();

    MgGeometry geometry = wktReaderWriter.Read("POINT XY (" + x.ToString().Replace(",",".") + " " + y.ToString().Replace(",",".") + ")");
    MgByteReader geometryByteReader = agfReaderWriter.Write(geometry);
    MgGeometryProperty geometryProperty = new MgGeometryProperty("GEOM", geometryByteReader);
    propertyCollection.Add(geometryProperty);

    return propertyCollection;
}

let's say I call my MakePoint method like this:

MakePoint("Point1", -97.485353, 38.548165);

When I select my point in my map I want to obtain the "NAME" property in the properties section of mapguide:

http://i46.tinypic.com/yjktx.png

But I get the properties section empty. How can I set the name and the value of a property in order to appear in 'Properties' section?

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.