Select to view content in your preferred language

How to get the total number of vertex of FeatureLayer?

1558
5
09-01-2011 10:59 PM
zhouning
Emerging Contributor
ESRI.ArcGIS.Client.FeatureLayer mFeatureLayer = new ESRI.ArcGIS.Client.FeatureLayer();
mFeatureLayer.Url = featureLayerUrl;
mFeatureLayer.MaxAllowableOffset=600;
MyMap.Layers.Add(mFeatureLayer);

Now I want to know how many vertex the Client side drawed when loaded the FeatureLayer.
The FeatureLayer is a polygon layer.
Because I want to know the effect of the property "maxableoffset".
0 Kudos
5 Replies
YipeiCheng
New Contributor
I am interested in this topic too, anyone who can give an answer?
0 Kudos
DeminHu
Deactivated User
I wonder if you can wrap the plogon to pointcollection, the get the point count.
0 Kudos
dotMorten_esri
Esri Notable Contributor
You should be able to do it uinsg a LINQ query. For example:
(from c in (from b in (from a in layer.Graphics select a.Geometry as Polygon) select b.Rings) select c.Count).Sum();
0 Kudos
zhouning
Emerging Contributor
Thanks your reply!
And I tried your suggestion, but the value of the variable 'VertexCount' didn't change when I changed the value of MaxAllowableOffset(Even set it as zero). The code as below:
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
  string featureLayerUrl = " http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServe...";

FeatureLayer mFeatureLayer = new ESRI.ArcGIS.Client.FeatureLayer();
mFeatureLayer.Url = featureLayerUrl;
mFeatureLayer.MaxAllowableOffset=861;
MyMap.Layers.Add(mFeatureLayer);
mFeatureLayer.Initialized += new EventHandler<EventArgs>(StartTimer);
mFeatureLayer.UpdateCompleted += new EventHandler(FeatureLayer_UpdateCompleted);

   void FeatureLayer_UpdateCompleted(object sender, EventArgs e)
        { VertexCount = (from c in (from b in (from a in mFeatureLayer.Graphics select a.Geometry as ESRI.ArcGIS.Client.Geometry.Polygon) select b.Rings) select c.Count).Sum();
}
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
I think the value of the VertexCount is the sum of the plygon's rings ,and it is the initial value,not the optimized value.In the other words,it is on server-side ,not the cilent -side.
0 Kudos
DominiqueBroux
Esri Frequent Contributor

I think the value of the VertexCount is the sum of the plygon's rings ,and it is the initial value,not the optimized value.In the other words,it is on server-side ,not the cilent -side.

The calculation is done at the client side. If you get the same result than at the server side, it means that your maxallowableoffset is not enough selective. Try with a higher value.
Note that the maxallowableoffset is a value given in map coordinates so the value is depending on your spatial reference and your map scale (e.g. a value that makes sense is 2*map.Resolution, it means that the distance between two vertices is at least 2 pixels).
0 Kudos