Selection based on a polygon...
Bill MacDonald
blmacdonald at agri.ns.ca
Thu Oct 26 10:47:34 EDT 2006
Hi,
I'm trying to query map features by drawing a polygon on the map and am
having nothing but trouble with this.
Here is a sample of the code I'm using:
Dim sLayerName As String = "Points"
Dim layerObj As MgLayer
layerObj = map.GetLayers().GetItem(sLayerName)
Dim featureResId As MgResourceIdentifier
featureResId = New
MgResourceIdentifier(layerObj.GetFeatureSourceId())
Dim featureGeometryName As String
featureGeometryName = layerObj.GetFeatureGeometryName()
Dim sClassName As String
sClassName = layerObj.GetFeatureClassName()
Dim queryOptions As New MgFeatureQueryOptions()
Dim sFilter As String = ""
queryOptions.SetFilter(sFilter)
Dim wktRW As New MgWktReaderWriter()
Dim geom As MgGeometry
Dim sPolygon As String
sPolygon = "POLYGON XY (("
While i < dCoords.Length
sPolygon = sPolygon & dCoords(0, 0) & " " & dCoords(0, 1) &
", "
i = i + 1
End While
If Right(sPolygon, 2) = ", " Then sPolygon = Left(sPolygon,
Len(sPolygon) - 2)
sPolygon = sPolygon & "))"
geom = wktRW.Read(sPolygon)
queryOptions.SetSpatialFilter(featureGeometryName, geom,
MgFeatureSpatialOperations.Inside)
Dim featureReader As MgFeatureReader
featureReader = featureService.SelectFeatures(featureResId,
sClassName, queryOptions)
' Process each item in the MgFeatureReader, displaying the owner
name And address
While featureReader.ReadNext()
Dim val As String
val = featureReader.GetString("NAME") & ", " &
featureReader.GetString("RPROPAD")
Response.Write(val & "<br />")
End While
I think I may have problems with the creation of the POLYGON but I'm
sure there are other things I am missing.
Any help would be greatly appreciated
Thanks
Billy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide_users/attachments/20061026/0c3e97d3/attachment.html
More information about the Mapguide_users
mailing list