Select to view content in your preferred language

GeometryService LengthsAsync units not being respected.

800
3
10-07-2010 08:45 AM
JasonScharf
Deactivated User
Hello,

I seem to be having problems getting GeometryTask's LengthsAsync call to respect measurement units.

I'm currently building a measurement tool for a map viewer. The map I am working with right now is in 102100 Web Mercator. In the future, I will be projecting geometry into more suitable projections for doing measurement.

No matter what I pass into LengthsAsync as my unit, I get back what appears to be meters. Why is this? The documentation for LengthsAsync says:


lengthUnit
    The length unit in which perimeters of polygons will be calculated. If unit is not specified, the units are derived from the Spatial Reference of the geometry.


My code:

                GeometryService geometryService = new GeometryService(GeometryServiceUri);
                geometryService.Failed += new EventHandler<TaskFailedEventArgs>(GeometryServiceMeasureSegment_Failed);
                geometryService.LengthsCompleted += new EventHandler<LengthsEventArgs>(GeometryServiceMeasureSegment_Completed);

                geometryService.LengthsAsync(geometryToMeasure, CurrentLengthUnit, true, null);


"CurrentLengthUnit" is a LinearUnit. Changing it between feet/kilometres/nautical miles/etc. has absolutely no effect on the resulting lengths.

Is anybody able to shed some light on why this is? Does it have to do with the projection I'm currently using (102100)? Why is lengthUnit ignored?!?
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
Can you try using the same parameters outside the SL app? You can use fiddler to see what requests are made by the SL app. Use the same parameters in your browser.  This will help us narrow down the issue. Try a different WKID too if you see any difference.

The sample in our SDK uses miles and it works fine. 
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Lengths
0 Kudos
JasonScharf
Deactivated User
Hi Jennifer,

I've tried a few different combination of projections and units, and the unit seems to be completely ignored.

Here is the URI I'm using:

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/lengths?sr=2264&polylines=[{"paths"%3a[[[1431405.14392891%2c562178.084391688]%2c[1412393.4856485%2c549785.157225033]]]}]&lengthUnit=9002&geodesic=true&f=json&


Changing lengthUnit does absolutely nothing. Is there some reason why sampleserver1 would ignore this?
0 Kudos
JasonScharf
Deactivated User
Ok, problem found. The geometry service I was using was on sampleserver1 running ArcGIS 9.31 and the lengthUnit parameter is not present.

I guess my issue now is that a user of mine may very well configure an ArcGIS 9.31 geometry service to be used in my viewer. I must detect this, and if so I will need to do all the unit conversion myself, based on what measurement units are being returned.

In this case, I'll need to obtain the measurement unit used for a particular spatial reference. Hopefully ArcGIS provides an easy way to do this.

Thanks for the help!
0 Kudos