ThinkGeo.com    |     Documentation    |     Premium Support

Unable to simplify Polygon

I am calling the following code


PolygonShape.Simplify(polygon, GeographyUnit.DecimalDegree, 50.1, DistanceUnit.Meter, SimplificationType.DouglasPeucker)


however I get the following exception:


A first chance exception of type 'System.ArgumentException' occurred in MapSuiteCore.dll

Input Geometry Type Is Not Valid

Parameter name: unit

   at ThinkGeo.MapSuite.Core.Conversion.x610393b3685ec97b(GeographyUnit x254e2e3a28873bf5)

   at ThinkGeo.MapSuite.Core.AreaBaseShape.Simplify(AreaBaseShape targetShape, GeographyUnit targetShapeUnit, Double tolerance, DistanceUnit toleranceUnit, SimplificationType simplificationType)


 


My map is set to be in DecimalDegrees.  Any help would be appreciated.  Thanks


.Ryan.


 


 



To give more background, I am processing some data on large areas in small chunks.  As the data processes, I would like to display the processed area on a map.  I am taking my already processed area and doing a Union on the newly processed area.  My problem is that this still keeps each of the verticies, so after doing a lot of areas, I run out of memory, so what I would like to do is remove any unnecessary verticies.


Thanks,


.Ryan.



Ryan, 
  
 We don’t support Simplify for a Shape which is under DecimalDegree, you can use the following code to work it around. 
  
 
PolygonShape polygonNeedToSimplify = new PolygonShape();
MultipolygonShape simplifiedShape = CustomSimplify(polygonNeedToSimplify, GeographyUnit.DecimalDegree, 50.1, DistanceUnit.Meter, SimplificationType.DouglasPeucker);                  

        public static MultipolygonShape CustomSimplify(AreaBaseShape targetShape, GeographyUnit targetShapeUnit, double tolerance, DistanceUnit toleranceUnit, SimplificationType simplificationType)
        {
            if (targetShapeUnit == GeographyUnit.DecimalDegree)
            {
                RectangleShape boundingBox = targetShape.GetBoundingBox();
                double latitude = boundingBox.GetCenterPoint().Y;
                double longitudeDifference = DecimalDegreesHelper.GetLongitudeDifferenceFromDistance(tolerance, toleranceUnit, latitude);
                // We set GeographyUnit and DistanceUnit both to meter here just because we want to set the same Unit, this is a workaround.
                 return PolygonShape.Simplify(targetShape, GeographyUnit.Meter, longitudeDifference, DistanceUnit.Meter, simplificationType);
            }
            else
            {
                return PolygonShape.Simplify(targetShape, targetShapeUnit, tolerance, toleranceUnit, simplificationType);
            }
        }
 
  
 Thanks, 
  
 Ben