[mapguide-users] Add geometry to SHP

sekko970 fabio.franceschini at techneteam.it
Thu Nov 5 12:08:57 EST 2009


I tryng to add a point to an existing SHP data connection in ASP.Net
application, using MG API.

Dim dataSource as String = "Library://.../MySHP.FeatureSource"
Dim dataSourceId As New MgResourceIdentifier(dataSource)

Dim MyProps As New MgPropertyCollection()
Dim agfRW As New MgAgfReaderWriter()
Dim geomFactory As New MgGeometryFactory

Dim myPoint As MgPoint =
geomFactory.CreatePoint(geomFactory.CreateCoordinateXY(X, Y))

'ID
Dim IDProp As New MgInt32Property("FeatID", IDValue)
MyProps.Add(IDProp)

'MyProp
Dim MyProp As New MgDoubleProperty("MyProp", MyPropValue)
MyProps.Add(MyProp)

'Geometry
Dim geomReader As MgByteReader = agfRW.Write(myPoint)
Dim geometryProp As New MgGeometryProperty("Geometry", geomReader)
MyProps.Add(geometryProp)

Dim propCollection As New MgBatchPropertyCollection()
propCollection.Add(MyProps)

Dim commands As New MgFeatureCommandCollection()
commands.Add(New MgInsertFeatures(MyFeatureName, propCollection))

Dim res As MgPropertyCollection = featureSrvc.UpdateFeatures(dataSourceId,
commands, False)
ReleaseReader(res, commands)

In ReleaseReader, I have the following error:
Unable to cast object of type 'OSGeo.MapGuide.MgStringProperty' to type
'OSGeo.MapGuide.MgFeatureProperty'.

In fact, res has only one property of type MgStringProperty: but why?

Have you any idea where is the error?
Thanks, Fabio

-- 
View this message in context: http://n2.nabble.com/Add-geometry-to-SHP-tp3953583p3953583.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list