AnsweredAssumed Answered

Buffer polygon intersect error : ArcObject Exception from HRESULT: 0x80040215

Question asked by nithumuthu279 on Jul 31, 2015

I try the get the plogon area with in buffer polygon area. But its always gives error. My error code is "ArcObject Exception from HRESULT: 0x80040215"

 

My code is given below :

 

  // Convert the JSON line to an ArcObjects Polyline

  var missing = Type.Missing;

  IPolyline routePolyline = new PolylineClass();

  foreach (var point in args.RoutePolyline)

  {

  (routePolyline as IPointCollection).AddPoint(

  new PointClass {X = point.X, Y = point.Y, SpatialReference = _webMercator},

  ref missing, ref missing);

  }

   routePolyline.SpatialReference = _webMercator;

 

  // Buffer it...

  var topologicalOperator = routePolyline as ITopologicalOperator;

  var routeBufferPolygon = topologicalOperator.Buffer(args.BufferDistance) as IPolygon;

 

  foreach (var layer in layersToArea)

  {

  var layerName = layer.Key;

  var jsonPropertyName = layer.Value;

 

 

  // Get the feature class and error out if it's not found

  var fc = Utilities.GetFeatureClass(_mapServer, layerName);

  if (fc == null)

  {

  var errMessage = string.Format("Can't find the feature class for '{0}'.", layerName);

  _logger.LogMessage(ServerLogger.msgType.error, "GetStats", -1000, errMessage);

  return ErrorResponse(errMessage);

  }

 

  // Setup a spatial filter for intersecting our buffer area

  ISpatialFilter sf = new SpatialFilterClass();

  sf.GeometryField = fc.ShapeFieldName;

  sf.Geometry = routeBufferPolygon;

  sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

 

  // Find the position of the "SQMI" field in the feature class.

  int nameFieldPosition = fc.FindField("SQMI");

 

  // Execute the query and iterate through the cursor's results.

  IFeatureCursor resultsFeatureCursor = fc.Search(sf, true);

 

  IFeature resultsFeature = null;

  double totalArea = 0.0;

  while ((resultsFeature = resultsFeatureCursor.NextFeature()) != null)

  {

  // problem accrued here

  IPolygon clippedResultsGeometry = (IPolygon)

   topologicalOperator.Intersect(resultsFeature.Shape,

   ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension);

  //clippedResultsGeometry.Densify(0, 0);  // Densify to maintain curved appearance when converted to JSON.

 

  // Get statistics.

  IArea area = (IArea)clippedResultsGeometry;

  totalArea += area.Area;

  }

  jsonResult.AddDouble(jsonPropertyName, totalArea);

  }

Outcomes