Zum Hauptinhalt gehen

How to get the length of a Polyline

Kommentare

5 Kommentare

  • Permanently deleted user

    Hi Josh

    if you have managed to get a Geometry.Polyline then you can feed that to the ArcGIS Server - Areas and Lengths Task.

    Regards

    Ralph

    0
  • Permanently deleted user

    Hi Ralph,

     

    Thanks for the quick reply and forgive my ignorance on the matter but how would I accomplish that in a workflow?  Are there some basic steps to calling the geometry service, supplying this polyline parameter, and getting an output?  Thanks Ralph.

     

     

    0
  • Permanently deleted user

    Hi Josh

    an alternative is the Lengths Activity. Here is an example:

    <Activity mc:Ignorable="sap sads" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="387,797" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"

     

     xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"

     

     xmlns:eac="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"

     

     xmlns:eacg="clr-namespace:ESRI.ArcGIS.Client.Geometry;assembly=ESRI.ArcGIS.Client"

     

     xmlns:eact="clr-namespace:ESRI.ArcGIS.Client.Tasks;assembly=ESRI.ArcGIS.Client"

     

     xmlns:esri="http://schemas.esri.com/arcgis/client/2009"

     

     xmlns:gce="clr-namespace:Geocortex.Core.Extensions;assembly=Geocortex.Core"

     

     xmlns:gfc="clr-namespace:Geocortex.Forms.Client;assembly=Geocortex.EssentialsWpfApi"

     

     xmlns:gfci="clr-namespace:Geocortex.Forms.Client.Items;assembly=Geocortex.EssentialsWpfApi"

     

     xmlns:gr="clr-namespace:Geocortex.Reporting;assembly=Geocortex.Reporting"

     

     xmlns:gwa="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow"

     

     xmlns:gwa1="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow.Activities"

     

     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

     

     xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"

     

     xmlns:s="clr-namespace:System;assembly=System.Core"

     

     xmlns:s1="clr-namespace:System;assembly=System"

     

     xmlns:s2="clr-namespace:System;assembly=mscorlib"

     

     xmlns:s3="clr-namespace:System;assembly=System.Reactive.Core"

     

     xmlns:s4="clr-namespace:System;assembly=System.ComponentModel.Composition"

     

     xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities"

     

     xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"

     

     xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"

     

     xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"

     

     xmlns:sl="clr-namespace:System.Linq;assembly=System.Core"

     

     xmlns:sw="clr-namespace:System.Windows;assembly=PresentationFramework"

     

     xmlns:sw1="clr-namespace:System.Windows;assembly=WindowsBase"

     

     xmlns:sw2="clr-namespace:System.Windows;assembly=PresentationCore"

     

     xmlns:swt="clr-namespace:System.Windows.Threading;assembly=WindowsBase"

     

     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

     

      <Sequence sap:VirtualizedContainerService.HintSize="347,1037" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">

     

        <Sequence.Variables>

     

          <Variable x:TypeArguments="esri:Polyline" Name="polyline1" />

     

          <Variable x:TypeArguments="esri:Graphic" Name="graphic1" />

     

          <Variable x:TypeArguments="scg:IList(esri:Graphic)" Name="iListOfGraphics" />

     

          <Variable x:TypeArguments="scg:List(x:Double)" Name="listOfLengths" />

     

          <Variable x:TypeArguments="esri:Geometry" Name="geometry1" />

     

        </Sequence.Variables>

     

        <sap:WorkflowViewStateService.ViewState>

     

          <scg:Dictionary x:TypeArguments="x:String, x:Object">

     

            <x:Boolean x:Key="IsExpanded">True</x:Boolean>

     

          </scg:Dictionary>

     

        </sap:WorkflowViewStateService.ViewState>

     

        <gwa1:CaptureGeometry CaptureType="[Geocortex.Workflow.Activities.GeometryCaptureType.Polyline]" sap:VirtualizedContainerService.HintSize="325,82" Result="[geometry1]" />

     

        <Assign sap:VirtualizedContainerService.HintSize="325,59">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="esri:Graphic">[graphic1]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="esri:Graphic">[new Graphic]</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <Assign sap:VirtualizedContainerService.HintSize="325,59">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="esri:Geometry">[graphic1.Geometry]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="esri:Geometry">[geometry1]</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <Assign sap:VirtualizedContainerService.HintSize="325,59">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="esri:SpatialReference">[graphic1.Geometry.SpatialReference]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="esri:SpatialReference">[new SpatialReference(102100)]</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <gwa1:CreateList x:TypeArguments="esri:Graphic" sap:VirtualizedContainerService.HintSize="325,59" Result="[iListOfGraphics]" />

     

        <gwa1:InsertIntoList x:TypeArguments="esri:Graphic" sap:VirtualizedContainerService.HintSize="325,105" Index="0" Item="[graphic1]" List="[iListOfGraphics]" />

     

        <gwa1:LengthsTask GeometryServiceUrl="http://geo.rdc.govt.nz/ArcGIS/rest/services/Utilities/Geometry/GeometryServer" Graphics="[iListOfGraphics]" sap:VirtualizedContainerService.HintSize="325,128" LengthUnit="[ESRI.ArcGIS.Client.Tasks.LinearUnit.Meter]" Results="[listOfLengths]" />

     

        <gwa1:Alert sap:VirtualizedContainerService.HintSize="325,82" Text="[listOfLengths(0).ToString]" />

     

      </Sequence>

     

    </Activity>

     

    Copy the code block above into a text editor.

    Save as  workflow.xaml (or some name better than that)

    Open in the workflow designer and run in the SImulator.

    During the running process you can select a polyline geometry example by clicking on the question mark at the righthand end of the input box.

    Hope that helps

    Ralph

     

    0
  • Permanently deleted user

    Great idea Ralph.  I added your Sequence to my workflow so that I could pass the Polyline into your Sequence.  I modified the spatial reference to my maps spatial reference (4326) and changed the length unit to Foot but the Alert is saying (System.Collections.Generic.List'1[System.Double]) at runtime.  Am I not able to convert a List<Double> to a string?

    0
  • Permanently deleted user

    Hi Ralp,

    I realized I needed to add a ForEach loop to loop through each Double and that works.  My only issue now is probably on my end but the distance value that is being output in the Alert is way off.  I set the spatial reference to my maps reference (4326) and set my linear units to feet but its way off so I'll keep adjusting that to see if I can find the correct parameters.

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.