[mapguide-users] Buffer is not working properly
padmini godavarthi
godavarthi.padmini at gmail.com
Tue Feb 16 02:18:36 EST 2010
Hi,
iam using mgos 2.1 with .net 2.0 on iis 6.0
i have created a buffer layer .now i want to retrieve parcels with in the
buffer area.so i wrote a code.but the parcels were not properly retrieved
from the bufferzone.
iam sending the screenshot of my application.
http://n2.nabble.com/file/n4578913/buffer.jpg
In the list box i want to displaying the parcels that are in the buffer
zone.but it also contains the parcels from outside of the buffer area
too...............
Here is my code for retrieve parcels in the buffer area
-------------------------------------------------------------------------------------------------------
Public Sub SelectBufferFeatures(ByVal LayerClassName As String, ByVal map As
MgMap, ByVal featureSrvc As MgFeatureService, ByVal sessionId As String,
ByVal mapWktSrs As String, ByVal srs As MgCoordinateSystem, ByVal srsMeasure
As MgCoordinateSystemMeasure)
Dim selectedLayers As MgLayerCollection = map.GetLayers()
Dim layer As MgLayer
Dim featureGeometry As MgGeometry = Nothing
Dim agfReaderWriter As MgAgfReaderWriter = New MgAgfReaderWriter()
Dim queryOptions As MgFeatureQueryOptions = New
MgFeatureQueryOptions()
For i As Integer = 0 To selectedLayers.GetCount() - 1
layer = selectedLayers.GetItem(i)
If (layer.GetName() = "PARCELS") Then
Dim layerClassName1 As String = layer.GetFeatureClassName()
Dim selectionString As String = ""
selectionString = selection.GenerateFilter(layer,
LayerClassName)
Dim LayerFeatureId As String = layer.GetFeatureSourceId()
Dim layerFeatureResource As MgResourceIdentifier = New
MgResourceIdentifier(LayerFeatureId)
queryOptions.SetFilter(selectionString)
featureReader =
featureService.SelectFeatures(layerFeatureResource, layerClassName1,
queryOptions)
Dim inputGeometries As MgGeometryCollection = New
MgGeometryCollection()
While (featureReader.ReadNext())
Dim featureGeometryData As MgByteReader =
featureReader.GetGeometry("Geometry")
featureGeometry =
agfReaderWriter.Read(featureGeometryData)
inputGeometries.Add(featureGeometry)
End While
Dim geometryFactory As MgGeometryFactory = New
MgGeometryFactory()
Dim mergedGeometries As MgMultiGeometry =
geometryFactory.CreateMultiGeometry(inputGeometries)
Dim bufferDist As Double =
srs.ConvertMetersToCoordinateSystemUnits(bufferRingSize)
bufferGeometry = mergedGeometries.Buffer(bufferDist,
srsMeasure)
Dim queryOptions1 As MgFeatureQueryOptions = New
MgFeatureQueryOptions()
queryOptions1.SetSpatialFilter("Geometry", bufferGeometry,
MgFeatureSpatialOperations.Within)
queryOptions1.AddFeatureProperty("PARCEL")
Dim featureReader1 As MgFeatureReader =
featureService.SelectFeatures(layerFeatureResource, layerClassName1,
queryOptions1)
While (featureReader1.ReadNext())
Dim value As String = featureReader1.GetString("PARCEL")
ListBox1.Items.Add(value)
End While
featureReader.Close()
map.Save(resourceService)
End If
Next
End Sub
where as bufferRingsize as double given by 500
plz let me know why its happening like this.
Regards,
Padmini G.
--
View this message in context: http://n2.nabble.com/Buffer-is-not-working-properly-tp4578913p4578913.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list