merge 2 featuresets
we need to set the map extent to the results of queries on 2 different feature sets. I can create the feature sets and envelopes for them, but I do not know how to append the two envelopes into a single geometry that I can get the extent for. Is there a sample for this, or can you provide a sample for this?
-
Hi Jeff,
You can union the two envelopes together by using the Envelope.Union() method in a VB expression (see http://resources.arcgis.com/en/help/silverlight-api/apiref/api_start.htm?ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Geometry.Envelope~Union.html).
envelope1.Union(envelope2)
--Ryan
0 -
Hi Ryan,
I tried using Union (in VBScript tool) to combine two envelopes from two featuresets but always get an error: Aborted exception: 'Type 'ESRI.ArcGIS.Client.Geometry.Envelope' in assembly 'ESRI.ArcGIS.Client, Version=3.0.0.396, Culture=neutral, PublicKeyToken = 29c6dd6e8553d944' is not marked as serializable.'
Here're the steps in the workflow: Query Task (to get a featureset) -> Get FeatureSet Extent -> repeat the first two steps to get 2nd featureset info -> VBScript (union first and second envelopes) -> set map extent
I was wondering if I miss some initial variables setup and/or using the wrong syntax. Please see my sample workflow below. Thanks
Chen-Ting
-----workflow-----
<Activity mc:Ignorable="sap" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="438,1261" 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: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:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Sequence sap:VirtualizedContainerService.HintSize="398,1221" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">
<Sequence.Variables>
<Variable x:TypeArguments="esri:Envelope" Name="envelope1" />
<Variable x:TypeArguments="esri:FeatureSet" Name="First" />
<Variable x:TypeArguments="esri:FeatureSet" Name="Second" />
<Variable x:TypeArguments="esri:Envelope" Name="envelope2" />
</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>
<gwa1:QueryTask sap:VirtualizedContainerService.HintSize="376,275" OutFields="*" QueryServiceUrl="http://sampleserver1.geocortex.com/ArcGIS/rest/services/CharlotteOperational/MapServer/2" Results="[First]" ReturnGeometry="True" SpatialRelationship="esriSpatialRelIntersects" Where="NAME = 'PINEVILLE ELEM'" />
<gwa1:GetFeatureSetExtent FeatureSet="[First]" sap:VirtualizedContainerService.HintSize="376,94" Result="[envelope1]" />
<gwa1:QueryTask sap:VirtualizedContainerService.HintSize="376,275" OutFields="*" QueryServiceUrl="http://sampleserver1.geocortex.com/ArcGIS/rest/services/CharlotteOperational/MapServer/2" Results="[Second]" ReturnGeometry="True" SpatialRelationship="esriSpatialRelIntersects" Where="NAME = 'OAKDALE ELEM'" />
<gwa1:GetFeatureSetExtent FeatureSet="[Second]" sap:VirtualizedContainerService.HintSize="376,94" Result="[envelope2]" />
<gwa1:VBScript sap:VirtualizedContainerService.HintSize="376,94" Script="VB1.Union(VB2)">
<gwa1:VBScript.Parameters>
<InOutArgument x:TypeArguments="esri:Envelope" x:Key="VB1">[envelope1]</InOutArgument>
<InOutArgument x:TypeArguments="esri:Envelope" x:Key="VB2">[envelope2]</InOutArgument>
</gwa1:VBScript.Parameters>
</gwa1:VBScript>
<gwa1:SetMapExtent Extent="[envelope1]" sap:VirtualizedContainerService.HintSize="376,65" />
</Sequence>
</Activity>0 -
Thanks Victoria. It worked!
0 -
Victoria? Who's Victoria and what did she suggest that worked? How is this helpful to others? 0 -
Victoria McDonald ex-employee 0 -
Nico, My point is that far too often in this support site, people somehow solve a problem through some private communication channel without posting the solution publicly. In this post a problem is posted, and then suddenly a “Thank You!” for a solution that the rest of us have no access to. How can anyone else with similar issues benefit from this post if the solution is not shared? It makes the entire post useless. Thanks, Lisa 0 -
Agree 0 -
Hi Lisa,
I'm certain Victoria did answer me in this post and her reply helped so that's why I thanked her here. I cannot retrieve Victoria's answers but I did created two (partial) workflows long time ago inspired by her reply and used them as my own examples. Hope these help.
(I was trying to attach workflows as text in the comment but the site won't allow me so I will try to explain what I did)
Example 1: use vbscript - this is more flexible as you can create the new table/featureset however required
turn featuresets to data tables
in vbscript tool, parameters - two existing datatables; one new empty datatables
read in each records in the table and put them in the new table
turn the combined datatable to featureset
here's the script:
T.Columns.Add ("A_TSR", Type.GetType("System.Int32"))
T.Columns.Add ("C_TSR", Type.GetType("System.Int32"))
dim i as integer
dim j as integer
dim x as integer
For i = 0 to T.Rows.Count-1 Step 1
T.Rows.Item(i).Item("A_TSR") = 0
T.Rows.Item(i).Item("C_TSR") = 0
Next
For i = 0 to T.Rows.Count-1 Step 1
For j = 0 to A.Rows.Count - 1 Step 1
If T.Rows.Item(i).Item("TSR_YEAR") = A.Rows.Item(j).Item("TSR_YEAR") then
T.Rows.Item(i).Item("A_TSR") = A.Rows.Item(j).Item("TSR_Active")
End If
Next
For x = 0 to C.Rows.Count - 1 Step 1
If T.Rows.Item(i).Item("TSR_YEAR") = C.Rows.Item(x).Item("TSR_YEAR") then
T.Rows.Item(i).Item("C_TSR") = C.Rows.Item(x).Item("TSR_Complete")
End If
Next
Next
example 2: if the featureset have the same columns, use a ForEach on featureset2 and AddtoCollection (featureset1) to combine them0 -
Thank you, Chen. 0 -
I dig through my notes...this is prob more related to the question of merging two extents. Use 'getfeaturesetextent' to get all featuresets' extents (envelopes). Use 'Assign' => envelope1= envelope1.Union(envelope2).
Chen-Ting0
Please sign in to leave a comment.
Comments
10 comments