[mapguide-users] intersection with two polygones
saloua wakrim
wakrimsaloua.wakrim at gmail.com
Fri Jun 5 07:23:24 EDT 2009
hi all developpers! i draw polygones in map on layer wich named "
champs_reels" (as my code shows it), i want to draw intersection betwen
these polygones and polygones of another layer wich named "batiments" (as my
code shows), i want drw a polygones wich constitute difference between both
of these polygones (on layers" champs_reels" and "batiments"), this my code
when i compile it it gives me this error:
A geometry exception occurred.
"TopologyException: side location conflict (893583,107815)", if some one has
any idea please tell it me, thanks a lot in advance: what's wrong???
Dim query As MgFeatureQueryOptions = New MgFeatureQueryOptions()
query.SetFilter("ID<>0")
Dim clalque_vue_cam As MgLayer = map.GetLayers().GetItem("champs_reels")
Dim featureReader As MgFeatureReader = clalque_vue_cam.SelectFeatures(query)
While featureReader.ReadNext()
Dim geometrypoly As MgByteReader = featureReader.GetGeometry(
"BufferGeometry")
Dim geometryReaderWriter As MgAgfReaderWriter = New MgAgfReaderWriter()
Dim poly As MgPolygon = geometryReaderWriter.Read(geometrypoly)
polygones.Add(poly)
End While
Dim propertyValues As MgPropertyCollection = New MgPropertyCollection()
Dim coordcol As MgCoordinateCollection = New MgCoordinateCollection()
Dim query2 As MgFeatureQueryOptions = New MgFeatureQueryOptions()
query2.SetFilter("FeatId<>0")
Dim batiments As MgLayer = map.GetLayers().GetItem("batiments")
Dim featureReader2 As MgFeatureReader = batiments.SelectFeatures(query2)
While featureReader2.ReadNext()
Dim geometrybati As MgByteReader = featureReader2.GetGeometry("Geometry")
Dim geometryReaderWriter2 As MgAgfReaderWriter = New MgAgfReaderWriter()
Dim batiment As MgPolygon = geometryReaderWriter2.Read(geometrybati)
'listbatiments.Add(batiment)
' If polygones(i).Touches(batiment) Then
Dim polyintersection As MgPolygon = polygones(i).Difference(batiment)
'Dim cord As MgCoordinateIterator = polyintersection.GetCoordinates()
'While cord.MoveNext()
'Dim cordonees As MgCoordinate = cord.GetCurrent()
'coordcol.Add(cordonees)
'Dim outring As MgLinearRing = geomfactory.CreateLinearRing(coordcol)
'Dim poly As MgPolygon = geomfactory.CreatePolygon(outring, Nothing)
propertyValues.Add(New MgGeometryProperty("BufferGeometry",
NewMgAgfReaderWriter().Write(polyintersection )))
Dim insert As MgInsertFeatures = New MgInsertFeatures(
"BufferLayerSchema2:BufferClass2", propertyValues)
Dim commands As MgFeatureCommandCollection = NewMgFeatureCommandCollection()
commands.Add(insert)
feature.UpdateFeatures(bufferFeatureResId2, commands, False)
End While
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090605/196e5931/attachment.html
More information about the mapguide-users
mailing list