This project is read-only.

Instantiating lots of Polygons

Nov 16, 2009 at 5:14 PM

I try to make objects of 500 polygons, 100-9000(!) nodes each. It is enormously time consuming. I use the code similar to this:

for(i=0;i<500;i++){

ptab[i] = new Polygon();

ptab[i].Points = new ObservableCollection<Point>();

for(sth)

{

ptab[i].Add(new Point(sth,sth);

  }

}

 

Am I doing this totally wrong way or it is impossible to have efectively such amount of items? How can I solve this problem?

Nov 16, 2009 at 9:55 PM

In Silveright there are a few ways to render vectors, as a UIElement these get full events, can be modified etc but also use more memeory and cpu to keep synced to the map etc. This is what we have currently and won't scale to millions of polygons.

The other option to explore is the writeablebitmap, if you just want to visualise these polygons then you can draw these onto a surface and add that to the map. We havn't yet built support for this but are looking for help to do it.

In terms of storage and processing of complex vectors the latest MapGeometry project uses the nettopologysuite to parse OGC WKB format into shapes for the map. I currently import complex polygons into SQL2008 geography and then pass these to DeepEarth in WKB to render. I recently enhanced this to do the WKB parsing in a background thread to increase performance. Additionally I've added a reduce function that simplifies polgons and high zoom levels to free up resources.