2011年4月27日 星期三

MgFeatureProperty

MgFeatureProperty is for object properties (ie. You have a feature class that has another nested class definition)

As for the process of adding points. It basically is

1. Create your feature source
1.1 Create a feature class definition for the feature source
1.2 Add any properties to the feature class
1.3 Set the geometry type of the feature class to points
1.4 Save this to a session resource.
1.5 Set the spatial context equal to the SRS of the current MgMap, otherwise the points you insert may not be where you think they are.
2. Create a layer definition that references the created feature source
2.1 Create or load the xml content for this layer definition
2.2 Save this to a session resource.
3. Create an MgInsertFeatures command
3.1 Set the first parameter className = name of your created feature class
3.2 Create a property collection
3.2.1 Fill the property collection with the values you want to insert. Each value corresponds to a property in your feature class.
3.2.2 For the point feature, insert a MgGeometryProperty object. As a MgGeometryProperty requires a MgByteReader for the geometry value, use a MgGeometryFactory to create your MgGeometry object and convert it to a MgByteReader with a MgAgfReaderWriter instance.
3.3 Add this MgInsertFeatures command to your MgFeatureCommandCollection
3.4 Finally, pass this MgFeatureCommandCollection to the UpdateFeatures() method of your MgFeatureService. Also give it the resource id of the feature source you created.
3.5 You may need to close any open MgFeatureReaders in the result of UpdateFeatures(), this is what the code you posted is trying to do.
4. Finally refresh the map on the client side (manual or programmatically) and the point should be there.

That's a high level overview of it all. There may be a few bits that are slightly incorrect, but that is the general process flow.