<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculate the Traveled distance in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/calculate-the-traveled-distance/m-p/1066756#M5518</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;One other way to compute the distance covered is from the Traversed Geometry returned by TrackingStatus. Something like this,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;private double calculateCumulativeLengthFromPolylineGeometry(Polyline polylineGeometry) {
    ImmutablePartCollection immutablePartCollection = polylineGeometry.getParts();
    double length = 0;
    for (ImmutablePart part:
         immutablePartCollection) {
      Iterator&amp;lt;Segment&amp;gt; it = part.iterator();
      while (it.hasNext()){
        Segment segment = it.next();
        Point startPoint = segment.getStartPoint();
        Point startPointMapSpatialReference = (Point) GeometryEngine.project(startPoint,mMapView.getSpatialReference());
        Point endPoint = segment.getEndPoint();
        Point endPointMapSpatialReference = (Point) GeometryEngine.project(endPoint,mMapView.getSpatialReference());
        double segmentLength = GeometryEngine.distanceBetween(startPointMapSpatialReference,endPointMapSpatialReference);
        length = length + segmentLength;
      }
    }
    //Length returned in meters, convert to Kilometers
    return length/1000;
  }&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Can get expensive if running on UI thread depending on number of segments in Geometry.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Rama&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jun 2021 05:47:16 GMT</pubDate>
    <dc:creator>RamaChintapalli</dc:creator>
    <dc:date>2021-06-10T05:47:16Z</dc:date>
    <item>
      <title>Calculate the Traveled distance</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/calculate-the-traveled-distance/m-p/1064013#M5509</link>
      <description>&lt;P&gt;Helo!&lt;BR /&gt;I'm working with a route app, and I would like to know if there is any way to calculate the total distance traveled? In this&amp;nbsp;&lt;A href="https://developers.arcgis.com/android/java/sample-code/navigate-route/" target="_self"&gt;example&lt;/A&gt;&amp;nbsp;the remaining distance was calculated according to the device's location. In class&amp;nbsp;&lt;A href="https://developers.arcgis.com/android/api-reference/reference/com/esri/arcgisruntime/navigation/TrackingStatus.Progress.html" target="_self"&gt;TrackingStatus&lt;/A&gt;&amp;nbsp;only the getRemainingDistance() function is presented.&lt;/P&gt;&lt;P&gt;If anyone has done something similar and could help me I would appreciate it.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 12:03:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/calculate-the-traveled-distance/m-p/1064013#M5509</guid>
      <dc:creator>GuilhermeFernandes96</dc:creator>
      <dc:date>2021-06-02T12:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Traveled distance</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/calculate-the-traveled-distance/m-p/1066756#M5518</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;One other way to compute the distance covered is from the Traversed Geometry returned by TrackingStatus. Something like this,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;private double calculateCumulativeLengthFromPolylineGeometry(Polyline polylineGeometry) {
    ImmutablePartCollection immutablePartCollection = polylineGeometry.getParts();
    double length = 0;
    for (ImmutablePart part:
         immutablePartCollection) {
      Iterator&amp;lt;Segment&amp;gt; it = part.iterator();
      while (it.hasNext()){
        Segment segment = it.next();
        Point startPoint = segment.getStartPoint();
        Point startPointMapSpatialReference = (Point) GeometryEngine.project(startPoint,mMapView.getSpatialReference());
        Point endPoint = segment.getEndPoint();
        Point endPointMapSpatialReference = (Point) GeometryEngine.project(endPoint,mMapView.getSpatialReference());
        double segmentLength = GeometryEngine.distanceBetween(startPointMapSpatialReference,endPointMapSpatialReference);
        length = length + segmentLength;
      }
    }
    //Length returned in meters, convert to Kilometers
    return length/1000;
  }&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Can get expensive if running on UI thread depending on number of segments in Geometry.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Rama&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 05:47:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/calculate-the-traveled-distance/m-p/1066756#M5518</guid>
      <dc:creator>RamaChintapalli</dc:creator>
      <dc:date>2021-06-10T05:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Traveled distance</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/calculate-the-traveled-distance/m-p/1066976#M5521</link>
      <description>&lt;P&gt;Hi Rama. Thank you so much for your answer. I've already managed to solve my problem in another way, but this method of yours seems to work very well.&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 16:54:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/calculate-the-traveled-distance/m-p/1066976#M5521</guid>
      <dc:creator>GuilhermeFernandes96</dc:creator>
      <dc:date>2021-06-10T16:54:22Z</dc:date>
    </item>
  </channel>
</rss>

