Select to view content in your preferred language

Get coordinate count only

855
4
04-17-2011 04:11 PM
BradBarnell
Regular Contributor
I there a way to get only the coordinate count or size of a feature with the one of the ESRI tasks?  I have some very large polygons that hang-up my application when a user tries to download and highlight the geometry.
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
As far as I know there is no query that can give you this. When you perform a query task with ReturnGeometry=True, you get the shape of the geometry. You may perform Linq query on this result. For example:
var largest = e.FeatureSet.Features.Max(g => g.Geometry.GetArea());
var graphic = e.FeatureSet.Features.FirstOrDefault(g => g.Geometry.GetArea() == largest);


However, this is not very efficient and the result may not be correct. A diagonal polyline's extent is not necessarily its true area. Also the number of vertices does not always guarantee that it will be the largest polygon.
public static class GeometryExtension
{
 public static double GetArea(this Geometry geom)
 {
  if (geom == null || geom.Extent == null) return 0;
  return geom.Extent.Height * geom.Extent.Width;
 }

 public static int GetVerticesCount(this Geometry geom)
 {
  if (geom is Polygon)
  {
   Polygon polygon = geom as Polygon;
   if (polygon.Rings == null) return 0;
   int count = 0;
   foreach (var pc in polygon.Rings)
    count += pc.Count;
   return count;
  }
  return 0;
 }
}
0 Kudos
DominiqueBroux
Esri Frequent Contributor
From ArcGIS server 10.0 you can also use the maxAllowableOffset option which can be used for generalizing geometries returned by a query, an identify or a find task.
0 Kudos
AnastasiaAourik
Emerging Contributor
On a slight tangent,  I do not see Return Count Only available via the Tasks.Query Class.
I have version 2.2.0.629

I see only ReturnIdsOnly and ReturnGeometry, but I cannot set ReturnCountOnly via the ArcGIS api for silverlight.

What gives???
0 Kudos
DominiqueBroux
Esri Frequent Contributor
On a slight tangent, I do not see Return Count Only available via the Tasks.Query Class.

The method is called ExecuteCountAsync.
It is available from SLAPI 2.1 but needs ArcGIS Server 10.0 SP1 to work.
0 Kudos