System.OutOfMemoryException was unhandled by user code
Message=Exception of type 'System.OutOfMemoryException' was thrown. Source=NetTopologySuite StackTrace: at GisSharpBlog.NetTopologySuite.Noding.SegmentNodeList.CreateSplitEdge(SegmentNode ei0, SegmentNode ei1) at GisSharpBlog.NetTopologySuite.Noding.SegmentNodeList.AddSplitEdges(IList edgeList) at GisSharpBlog.NetTopologySuite.Noding.SegmentString.GetNodedSubstrings(IList segStrings, IList resultEdgelist) at GisSharpBlog.NetTopologySuite.Noding.SegmentString.GetNodedSubstrings(IList segStrings) at GisSharpBlog.NetTopologySuite.Noding.MCIndexNoder.GetNodedSubstrings() at GisSharpBlog.NetTopologySuite.Operation.Buffer.BufferBuilder.ComputeNodedEdges(IList bufferSegStrList, IPrecisionModel precisionModel) at GisSharpBlog.NetTopologySuite.Operation.Buffer.BufferBuilder.Buffer(IGeometry g, Double distance) at GisSharpBlog.NetTopologySuite.Operation.Buffer.BufferOp.BufferOriginalPrecision() at GisSharpBlog.NetTopologySuite.Operation.Buffer.BufferOp.ComputeGeometry() at GisSharpBlog.NetTopologySuite.Operation.Buffer.BufferOp.GetResultGeometry(Double distance) at GisSharpBlog.NetTopologySuite.Operation.Buffer.BufferOp.Buffer(IGeometry g, Double distance) at GisSharpBlog.NetTopologySuite.Geometries.Geometry.Buffer(Double distance) at ThinkGeo.MapSuite.Core.AreaBaseShape.Union(IEnumerable`1 areaShapes) at MapTest.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Users\a09zmzz\Documents\Visual Studio 2010\Projects\MapTest\MapTest\WebForm1.aspx.cs:line 238 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) InnerException:
Well I have to create a shape made of ZIP5 codes… how should I do that??? My expectation was based on the fact that ThinkGeo was providing a solution to handle this kind of problem! isn’t it?
One thing I want to make sure first. Are you using the same method for unioning polygons as you can see in those two Code Community samples, Dissolve on Shapefile and Dissolve with Statistics?
In those samples, you are going to find a fast and reliable way to union polygons together. The end result is in a shapefile but this is basically the same method in unioning as for InMemoryFeatureLayer. If you are still having problem, I would suggest you send us your zip code shape and we will examine it. Thank you.
I was able to make my function to work well but the response time is not good… for instance if you need to union let say 10 US states (10 features) it takes about 15 seconds to complete! I ran for 6 hours and generate 41 shapes (one per sales rep) each shape is made of up to 600 zips shapes.
I really need to find a better way to solve this problem! the positive side is that the colorized InMemoryFeatureLayer where there is one shape zip is about 831MB… now the InMemoryFeatureLayer with only 41 shapes is 95MB! much better to load.
any advice on how to optimize the union operation?
Yes. You are right. The most efficient way to union polygons together is to first add them into a collection and then use the static function Union of PolygonShape to union them all in one step.
//First, add all the polygons into a collection Collection<AreaBaseShape> polygonShapes = new Collection<AreaBaseShape>();
Collection<Feature> features = shapeFileFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
//Second, uses the PolygonShape.Union static method to union all the shapes in one step. MultipolygonShape multiPolygonShape = PolygonShape.Union(polygonShapes);