2

Does the IGeometryServer2 interface work in desktop applications? My solution is an Add-in for ArcGIS 10. I'm currently passing it two valid polygon features that are in a projected coordinate system. I call the GetDistanceGeodesic() method in the following manner but it always returns infinity.

IGeometryServer2 geomServer2 = new GeometryServerClass();
var PCS = distFeat.ShapeCopy.SpatialReference as IProjectedCoordinateSystem;    
ILinearUnit unit = PCS.CoordinateUnit;    
double _dTestDist = geomServer2.GetDistanceGeodesic(distFeat.ShapeCopy.SpatialReference, distFeat.Shape, distFeat2.Shape, unit);

All the inputs have the expected values while stepping through in debug mode. I also tried using WGS84 but the results were the same.

Rich Wawrzonek
  • 2,066
  • 12
  • 25
  • 1
    Somewhat related (you might need to use pe.dll for this): http://gis.stackexchange.com/q/1351/753 – blah238 Apr 17 '13 at 23:05
  • Thanks, I did see that question. I was hoping to get this interface working to simplify things. – Rich Wawrzonek Apr 17 '13 at 23:22
  • @Rich Wawrzonek Hi, are you going to use ArcGIS Server? GeometryServerClass is GeometryService which hosted by ArcGIS Server. – Darksanta Apr 17 '13 at 23:36
  • No, this application is for desktop. One polygon comes from a file geodatabase feature class and the other from the ArcMap user interface (in memory). – Rich Wawrzonek Apr 18 '13 at 00:29
  • 1
    You can take a look at http://blogs.esri.com/esri/arcgis/2011/07/21/calculating_geodesic/. According to that, after 10.0 sp2 you can calculate geodesic distances using the Calculate Field tool. – travis Apr 18 '13 at 00:55
  • @Rich Wawrzonek Most of sample which calculate geodetic line is point to point. But your question is Polygon to Polygon. I'm considering how to calculate it. The most easiest way is densify both polygon and make point array, then calculate geodetic length for all points. finally the minimum value of length is the geodetic line. But I am concerned about the performance. – Darksanta Apr 18 '13 at 01:41
  • @Darksanta I think there are edge cases in which that would yield inaccurate results. Consider the case of a square and a triangle, where the closest point of the triangle to the square is somewhere along the edge of the square. The accuracy would then depend on the level of densification, which may or may not be an acceptable compromise. – blah238 Apr 18 '13 at 02:18
  • @travis thanks for the link, I didn't know about the new field calc functionality. Unfortunately that won't work in my program. I'm looping many iterations for a complex polygon so the geoprocessor is too slow. Thanks for input Darksanta, blah238 hit the nail on the head for why that won't work. Plus my polygon is too large to calculate a distance for all points if it were densified, performance would be poor. – Rich Wawrzonek Apr 18 '13 at 21:31

0 Answers0