<?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 length of pipes within a polygon in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calculate-the-length-of-pipes-within-a-polygon/m-p/710461#M66055</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please try adding below line in your length parameters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lengthParams.calculationType = "geodesic";&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Jun 2014 10:55:36 GMT</pubDate>
    <dc:creator>MuditAgarwal</dc:creator>
    <dc:date>2014-06-13T10:55:36Z</dc:date>
    <item>
      <title>Calculate the length of pipes within a polygon</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calculate-the-length-of-pipes-within-a-polygon/m-p/710460#M66054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am calculating the total length of poly-lines (pipes) within a polygon. I am querying the layer and I am getting the result. The problem is that when I'm comparing the results with ArcMap I have some difference in the length. My code is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;featureLayer.on("click", function (evt) {
 map.graphics.clear();
 var highlightGraphic = new Graphic(evt.graphic.geometry, highlightSymbol);
 map.graphics.add(highlightGraphic);

 var query = new Query();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 var queryTask = new QueryTask("feature layer with polylines");
 query.geometry = evt.graphic.geometry;
 query.returnGeometry = true;
 query.outSpatialReference = map.spatialReference;
 query.outFields = ["*"];

 queryTask.execute(query, function (results) {
&amp;nbsp; var lengthParams = new LengthsParameters();

&amp;nbsp; var pipesList = [];
&amp;nbsp; for (var i = 0; i &amp;lt; results.features.length; i++) {
&amp;nbsp;&amp;nbsp; pipesList.push(results.features&lt;I&gt;.geometry);
&amp;nbsp; }
&amp;nbsp; lengthParams.polylines = pipesList;
&amp;nbsp; lengthParams.lengthUnit = GeometryService.UNIT_KILOMETER;
&amp;nbsp; geometryService.lengths(lengthParams);
});

dojo.connect(geometryService, "onLengthsComplete", outputDistance);

function outputDistance(result) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var total = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var i = 0; i &amp;lt; result.lengths.length; i++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; total += result.lengths&lt;I&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("Count: " + result.lengths.length + " Distance: "&amp;nbsp; + total.toFixed(2) + "km");
}

&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Am I doing something wrong with my code? Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2014 12:49:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calculate-the-length-of-pipes-within-a-polygon/m-p/710460#M66054</guid>
      <dc:creator>ChristianDebono</dc:creator>
      <dc:date>2014-04-15T12:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the length of pipes within a polygon</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calculate-the-length-of-pipes-within-a-polygon/m-p/710461#M66055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please try adding below line in your length parameters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lengthParams.calculationType = "geodesic";&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jun 2014 10:55:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/calculate-the-length-of-pipes-within-a-polygon/m-p/710461#M66055</guid>
      <dc:creator>MuditAgarwal</dc:creator>
      <dc:date>2014-06-13T10:55:36Z</dc:date>
    </item>
  </channel>
</rss>

