I am developing an application using ArcGIS .net add-in. An application generates some maps based on point and polygon datasets. In that, I am able to find the polygons within the search distance. Now, wanted to create a nearest point on these polygons. I am using ReturnNearestPoint() function of Proximity operator for this purpose.ReturnNearestPoint() method returns an very big value like (x= 443276.1254, y=3357699.12547). For a layer having single polygon, it returns correct values (lat/long). Can you please help me in this?
Here is the code
Private Sub GetSelectedFeatures(ByVal key As String, ByVal db As String, ByRef featureLayer As IFeatureLayer, ByRef pnt As IPoint, ByRef RadiusSearchMDB As OleDb.OleDbConnection) Dim featureSelection As IFeatureSelection = CType(featureLayer, IFeatureSelection) Dim selectionSet As ISelectionSet = featureSelection.SelectionSet Dim cursor As IFeatureCursor selectionSet.Search(Nothing, False, cursor) Dim pFeature As IFeature pFeature = cursor.NextFeature While Not pFeature Is Nothing Dim pPoint As IPoint pPoint = New Point pPoint.X = pnt.X pPoint.Y = pnt.Y CreateNearestPointOnPolygon(pPoint, pFeature) pFeature = cursor.NextFeature End While End Sub Private Function CreateNearestPointOnPolygon(pPoint As IPoint, ByRef pFeature As IFeature) As geoCode Dim pPoint2 As IPoint pPoint2 = New Point Dim pRelOp As IRelationalOperator pRelOp = pFeature.Shape Dim res As Boolean res = pRelOp.Contains(pPoint) Dim pProximity As IProximityOperator pProximity = pFeature.Shape pPoint2 = pProximity.ReturnNearestPoint(pPoint, esriSegmentExtension.esriNoExtension) Dim Geo2 As geoCode Geo2.lon = pPoint2.X Geo2.lat = pPoint2.Y Return Geo2 End Function
أكثر...
Here is the code
Private Sub GetSelectedFeatures(ByVal key As String, ByVal db As String, ByRef featureLayer As IFeatureLayer, ByRef pnt As IPoint, ByRef RadiusSearchMDB As OleDb.OleDbConnection) Dim featureSelection As IFeatureSelection = CType(featureLayer, IFeatureSelection) Dim selectionSet As ISelectionSet = featureSelection.SelectionSet Dim cursor As IFeatureCursor selectionSet.Search(Nothing, False, cursor) Dim pFeature As IFeature pFeature = cursor.NextFeature While Not pFeature Is Nothing Dim pPoint As IPoint pPoint = New Point pPoint.X = pnt.X pPoint.Y = pnt.Y CreateNearestPointOnPolygon(pPoint, pFeature) pFeature = cursor.NextFeature End While End Sub Private Function CreateNearestPointOnPolygon(pPoint As IPoint, ByRef pFeature As IFeature) As geoCode Dim pPoint2 As IPoint pPoint2 = New Point Dim pRelOp As IRelationalOperator pRelOp = pFeature.Shape Dim res As Boolean res = pRelOp.Contains(pPoint) Dim pProximity As IProximityOperator pProximity = pFeature.Shape pPoint2 = pProximity.ReturnNearestPoint(pPoint, esriSegmentExtension.esriNoExtension) Dim Geo2 As geoCode Geo2.lon = pPoint2.X Geo2.lat = pPoint2.Y Return Geo2 End Function
أكثر...