Zum Hauptinhalt gehen

create polyline from mappoints collection - how to

Kommentare

10 Kommentare

  • Permanently deleted user

    Hi Jeff,

    Try using an InvokeMethod activity instead of an Assign statement. Leave TargetType as (null), set TargetObject to polyline.Paths, set MethodName to Add, and create an In parameter with a Type of PointCollection, and a Value of your point collection variable, pPcPolyline.

    Because the Add method doesn't output a new polyline, you cannot assign it to a variable. This is why your Assign statement wasn't working.

    -Victoria

    0
  • Permanently deleted user

    Victoria--

    I am sorry, but I cannot seem to get the right type of collection for my map points. I need to create a collection to hold the map points, then add the map points to the collection.  I seem to be caught up in some kind of loop where none of the collection types get along.  So...what should the collection type be for adding map points?  so if I create a collection for this, what type should it be, then when I add the map points, what type should it be?  and finally when I invoke method, it does not like the collection type either.  This is all confusing to me.  Can you help me here.  I have enclosed my workflow xaml file.  I am getting errors on the invoke method, but check the rest too.

    <Activity mc:Ignorable="sap" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="304,1060" 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.ServiceModel" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

     

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

     

        <Sequence.Variables>

     

          <Variable x:TypeArguments="esri:MapPoint" Name="point1" />

     

     

     

    This is a building block test of course.  I plan to build a bearing and distance workflow once I learn how to build a line from points.

    Jeff

     

          <Variable x:TypeArguments="esri:MapPoint" Name="point2" />

     

          <Variable x:TypeArguments="esri:PointCollection" Name="pPCPolyline" />

     

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

     

          <Variable x:TypeArguments="x:Double" Name="X1" />

     

          <Variable x:TypeArguments="x:Double" Name="Y1" />

     

          <Variable x:TypeArguments="x:Double" Name="X2" />

     

          <Variable x:TypeArguments="x:Double" Name="Y2" />

     

        </Sequence.Variables>

     

        <sap:WorkflowViewStateService.ViewState>

     

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

     

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

     

          </scg2:Dictionary>

     

        </sap:WorkflowViewStateService.ViewState>

     

        <Assign sap:VirtualizedContainerService.HintSize="242,57">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="x:Double">[point1.X]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="x:Double">-13482253</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <Assign sap:VirtualizedContainerService.HintSize="242,57">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="x:Double">[point1.Y]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="x:Double">5584042</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <Assign sap:VirtualizedContainerService.HintSize="242,57">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="x:Double">[point2.X]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="x:Double">-1326100</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <Assign sap:VirtualizedContainerService.HintSize="242,57">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="x:Double">[point2.Y]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="x:Double">5557872</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <AddToCollection x:TypeArguments="esri:MapPoint" Collection="[pPCPolyline]" DisplayName="AddToCollection&lt;MapPoint&gt;" sap:VirtualizedContainerService.HintSize="242,22" Item="[point1]" />

     

      </Sequence>

     

    </Activity>
    0
  • Permanently deleted user

    <Activity mc:Ignorable="sap" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="304,1060" 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.ServiceModel" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

     

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

     

        <Sequence.Variables>

     

          <Variable x:TypeArguments="esri:MapPoint" Name="point1" />

     

          <Variable x:TypeArguments="esri:MapPoint" Name="point2" />

     

          <Variable x:TypeArguments="esri:PointCollection" Name="pPCPolyline" />

     

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

     

          <Variable x:TypeArguments="x:Double" Name="X1" />

     

          <Variable x:TypeArguments="x:Double" Name="Y1" />

     

          <Variable x:TypeArguments="x:Double" Name="X2" />

     

          <Variable x:TypeArguments="x:Double" Name="Y2" />

     

        </Sequence.Variables>

     

        <sap:WorkflowViewStateService.ViewState>

     

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

     

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

     

          </scg2:Dictionary>

     

        </sap:WorkflowViewStateService.ViewState>

     

        <Assign sap:VirtualizedContainerService.HintSize="242,57">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="x:Double">[point1.X]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="x:Double">-13482253</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <Assign sap:VirtualizedContainerService.HintSize="242,57">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="x:Double">[point1.Y]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="x:Double">5584042</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <Assign sap:VirtualizedContainerService.HintSize="242,57">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="x:Double">[point2.X]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="x:Double">-1326100</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <Assign sap:VirtualizedContainerService.HintSize="242,57">

     

          <Assign.To>

     

            <OutArgument x:TypeArguments="x:Double">[point2.Y]</OutArgument>

     

          </Assign.To>

     

          <Assign.Value>

     

            <InArgument x:TypeArguments="x:Double">5557872</InArgument>

     

          </Assign.Value>

     

        </Assign>

     

        <AddToCollection x:TypeArguments="esri:MapPoint" Collection="[pPCPolyline]" DisplayName="AddToCollection&lt;MapPoint&gt;" sap:VirtualizedContainerService.HintSize="242,22" Item="[point1]" />

     

      </Sequence>

     

    </Activity>
    0
  • Permanently deleted user

    Hi Jeff,

    You were almost there. All you needed was to initialize your variables, and add the Invoke Method activity to the end.

    -Victoria

     

    <Activity mc:Ignorable="sap" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="304,748" 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.ServiceModel" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=System" xmlns:sco1="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">   <Sequence sap:VirtualizedContainerService.HintSize="264,708" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">     <Sequence.Variables>       <Variable x:TypeArguments="esri:MapPoint" Default="[new Esri.ArcGIS.Client.Geometry.MapPoint()]" Name="point1" />       <Variable x:TypeArguments="esri:MapPoint" Default="[new Esri.ArcGIS.Client.Geometry.MapPoint()]" Name="point2" />       <Variable x:TypeArguments="esri:PointCollection" Default="[new Esri.ArcGIS.Client.Geometry.PointCollection()]" Name="pPCPolyline" />       <Variable x:TypeArguments="esri:Polyline" Default="[new Esri.ArcGIS.Client.Geometry.Polyline()]" Name="polyline" />       <Variable x:TypeArguments="x:Double" Name="X1" />       <Variable x:TypeArguments="x:Double" Name="Y1" />       <Variable x:TypeArguments="x:Double" Name="X2" />       <Variable x:TypeArguments="x:Double" Name="Y2" />     </Sequence.Variables>     <sap:WorkflowViewStateService.ViewState>       <scg2:Dictionary x:TypeArguments="x:String, x:Object">         <x:Boolean x:Key="IsExpanded">True</x:Boolean>       </scg2:Dictionary>     </sap:WorkflowViewStateService.ViewState>     <Assign sap:VirtualizedContainerService.HintSize="242,58">       <Assign.To>         <OutArgument x:TypeArguments="x:Double">[point1.X]</OutArgument>       </Assign.To>       <Assign.Value>         <InArgument x:TypeArguments="x:Double">-13482253</InArgument>       </Assign.Value>     </Assign>     <Assign sap:VirtualizedContainerService.HintSize="242,58">       <Assign.To>         <OutArgument x:TypeArguments="x:Double">[point1.Y]</OutArgument>       </Assign.To>       <Assign.Value>         <InArgument x:TypeArguments="x:Double">5584042</InArgument>       </Assign.Value>     </Assign>     <Assign sap:VirtualizedContainerService.HintSize="242,58">       <Assign.To>         <OutArgument x:TypeArguments="x:Double">[point2.X]</OutArgument>       </Assign.To>       <Assign.Value>         <InArgument x:TypeArguments="x:Double">-1326100</InArgument>       </Assign.Value>     </Assign>     <Assign sap:VirtualizedContainerService.HintSize="242,58">       <Assign.To>         <OutArgument x:TypeArguments="x:Double">[point2.Y]</OutArgument>       </Assign.To>       <Assign.Value>         <InArgument x:TypeArguments="x:Double">5557872</InArgument>       </Assign.Value>     </Assign>     <AddToCollection x:TypeArguments="esri:MapPoint" Collection="[pPCPolyline]" DisplayName="AddToCollection&lt;MapPoint&gt;" sap:VirtualizedContainerService.HintSize="242,22" Item="[point1]" />     <InvokeMethod sap:VirtualizedContainerService.HintSize="242,130" MethodName="Add">       <InvokeMethod.TargetObject>         <InArgument x:TypeArguments="sco:ObservableCollection(esri:PointCollection)">[polyline.Paths]</InArgument>       </InvokeMethod.TargetObject>       <InArgument x:TypeArguments="esri:PointCollection">[pPCPolyline]</InArgument>     </InvokeMethod>   </Sequence> </Activity>
    0
  • Permanently deleted user

    I will study this tomorrow - but thanks for your help!!!

    0
  • Permanently deleted user

    I don't know how to append the count to a base string like "point" + Count.tostring  so i can create numbered points point1, point2, point3, point4.  I am changing the xy values of my points, point1.X = point1.X + 50000 using assign but the change doesnt seem like it sticks.  my markers are the same place and when I add these changed points to a point collection, the values are the same., so i am thinking I need to create a new point entry.  any suggestions on how to add a variable such as count to a basename?

    J

    0
  • Permanently deleted user

    I'm afraid you just can't dynamically create variable names like this (I think that's what you are trying to do). Just reuse the same 'point' variable in a loop to hold the different points you need and add each one to the collection.

    If you find that altering the value of one point alters the values of _all_ the points you have added -- you might actually be adding the same point over and over again. To ensure that you are assigning a new point each time, explicitly create one:

    point = new MapPoint() 

    Do that at the top of the loop, then assign x and y, then add it to the collection.

    0
  • Permanently deleted user

    OK--

    Thats right, I tried and it works! Thank you for the advice!

    J

    0
  • Permanently deleted user
    Hello,

     

    I realize this point is 5 years old, I'm trying to do the same thing and get quite get it to work.  I have a pair of coordinates and just need to draw a line between them. 

     

    Thank you,

     

    Stephanie

     

     
    0
  • Amanda Frech
    Hi Stephanie,

     

    The methods discussed here previously will still work for the most part, but we can replace the InvokeMethod activity that Victoria mentioned with the AddToCollection activity.  Are you looking to get the line added to an ArcGIS server layer?  Or do you have a different result in mind?

     

    A workflow to add a line as a new feature based on a pair of coordinates would look something like this.  It's mostly just creating new objects and adding them to collections:
    1. Create two MapPoint variables (if you don't already have your points in this format).  Set their x and y coordinates (eg point1.X = 123445)
    2. Use AddToCollection to put the MapPoints in a new PointCollection object
    3. Create a new Polyline and set its spatial reference (eg polyline1.SpatialReference = New ESRI.ArcGIS.Client.Geometry.SpatialReference(102100))
    4. Use AddToCollection to put the PointCollection in the polyline.Paths property
    5. Create a new graphic and set its Geometry property to your polyline variable
    6. Create a new featureset  and use AddToCollection to add the Graphic to the featureSet.Features property
    7. Then you can use AddFeatures to get your featureset added to your layer
    For this sort of thing, this reference (http://help.arcgis.com/en/webapi/wpf/apiref/ESRI.ArcGIS.Client.html) is pretty helpful to have on hand to keep track of how all the objects relate to each other.

     

    Hope that helps!

     

    -Amanda
    0

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