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?

  • 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 Sep 18 '12 at 18:53
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

  • Thank you Steve, this indeed works, I had figured this out a while ago but forgot to edit the question, thank you! – alessandro ferrucci Sep 19 '12 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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