1

I have a Polyline that I draw on the map and I would like to get its distance in meters.

right now it's not working, basically what I have is

   distanceSeg=new Polyline();
   double  len1=distanceSeg.calculateLength2D();
   double m_len=
         Unit.convertUnits(len1,Unit.create(AngularUnit.Code.DEGREE),Unit.create(LinearUnit.Code.METER));

The call to Unit.convertUnits throws a GeometryException with "invalid_call".

Any ideas?

1
  • I think it's failing because the input/output unit 'types' are not the same. That is, not both angular nor linear (nor areas). The help doc for calculateLength2D does say that if the coordinate system is gcs, use geodesicLength from GeometryEngine as @Steve says in the answer below.
    – mkennedy
    Commented Sep 18, 2012 at 18:53

1 Answer 1

2

I'm not overly familiar with the Android API but I am wondering if GeometryEngine.geodesicLength might be an easier approach.

GeometryEngine.geodesicLength javadoc

1
  • Thank you Steve, this indeed works, I had figured this out a while ago but forgot to edit the question, thank you! Commented Sep 19, 2012 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.