We've been getting the following exception on occasion when calling the AreaBaseShape.GetArea() method:
An item with the same key has already been added
We use a highlight overlay based on a school district shape file. The complexity of the district shapes causes poor performance when the highlight overlay is being loaded by the browser, so we're simplifying each district feature before adding it to the HighlightOverlay.Features collection. To optimize the simplification without collapsing small features, we first check the area of the feature to determine what tolerance value to use during feature simplification. It is at this point that we're using the GetArea() method, passing in the map unit (DecimalDegrees) and area unit (SquareMiles).
We've not seen this error in our development environment (Win XP Pro x86/IIS5, Win Server 2003 x86/IIS6), but have seen it occur a few times now on the production server (Win Server 2008 x64/IIS7). The relevant portion of the stack trace is below:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at ThinkGeo.MapSuite.Core.Conversion.x403670ed8bbdb849()
at ThinkGeo.MapSuite.Core.Conversion.ConvertMeasureUnits(Double amount, DistanceUnit fromUnit, DistanceUnit toUnit)
at ThinkGeo.MapSuite.Core.Vertex.x89dc586698d2da52(Double xce919ea4a4b048be, Double x4e6c8c21e101dfe6, GeographyUnit x4a9671edd975c880, DistanceUnit xd7f8808b671067a9)
at ThinkGeo.MapSuite.Core.RingShape.TranslateByOffsetCore(Double xOffsetDistance, Double yOffsetDistance, GeographyUnit shapeUnit, DistanceUnit distanceUnit)
at ThinkGeo.MapSuite.Core.BaseShape.TranslateByOffset(Double xOffsetDistance, Double yOffsetDistance, GeographyUnit shapeUnit, DistanceUnit distanceUnit)
at ThinkGeo.MapSuite.Core.PolygonShape.TranslateByOffsetCore(Double xOffsetDistance, Double yOffsetDistance, GeographyUnit shapeUnit, DistanceUnit distanceUnit)
at ThinkGeo.MapSuite.Core.BaseShape.TranslateByOffset(Double xOffsetDistance, Double yOffsetDistance, GeographyUnit shapeUnit, DistanceUnit distanceUnit)
at ThinkGeo.MapSuite.Core.PolygonShape.x22a246417c5ad5c6(PolygonShape xebf0a6abef184fe6)
at ThinkGeo.MapSuite.Core.PolygonShape.GetAreaCore(GeographyUnit shapeUnit, AreaUnit returningUnit)
at ThinkGeo.MapSuite.Core.AreaBaseShape.GetArea(GeographyUnit shapeUnit, AreaUnit returningUnit)
at ThinkGeo.MapSuite.Core.MultipolygonShape.GetAreaCore(GeographyUnit shapeUnit, AreaUnit returningUnit)
at ThinkGeo.MapSuite.Core.AreaBaseShape.GetArea(GeographyUnit shapeUnit, AreaUnit returningUnit)
Note that our feature simplification method is called the first time the map is loaded, at which point we are storing the simplied districts in a GeoCollection<Feature> in HttpRuntime.Cache. The cached collection is used to populate the HighlightOverlay.Features collection on subsequent page loads.