This project has moved and is read-only. For the latest updates, please go here.

How to render a Region

Topics: Algorithms, SharpMap v0.9 / v1.x, WinForms Controls
Aug 2, 2010 at 8:18 AM


Can anybody help me with rendering a part of map image?

I have several layers in my desktop application, and some of them represent objects, which can change state. I use 2 layers for it. For example, if my object in normal state - its in layer named "normal", if it's in 'alert' state - I delete a point from 'normal' layer and add a point with the same coordinates to a layer named 'alertLayer', etc. Points in "normal" layer have green icon, in "alert" layer - red icon. There is a problem - if my map includes many objects (in other layers - buildings, roads, rivers, etc.) - this operation (moving a point from one layer to another) taket a lot of time (because rendering takes a lot of time). Can I re-render only a little region, which includes only my point - which I move from one layer to another? Or may be there is any other way to solve this problem?


Aug 5, 2010 at 8:37 PM

Make two map images: one with the normal points and the the alert points and the other with all the other stuff.
Place the first one with the points above the second one, make it transparant and rerender only the point map when the state  changes.

Aug 6, 2010 at 8:43 AM

Well, it will let me combine the result map image from two parts. But how to operate both map images at the same time? If I scroll the map, for example? Are there any methods to do it? The map images should scroll, zoom in and zoom out simultaniously.

Aug 9, 2010 at 8:54 AM
Edited Aug 9, 2010 at 9:00 AM
Scrolling and zooming will reintroduce the problem of the long render times again, because the background map will have to be rerendered completely again each time you zoom or pan. I think you should try to optimize your background data with roads rivers etc. If you have shapefiles, you could add a spatial index when setting the datasource. Removing all unnecessary features from your datasets might also help. In Holland it always helps to remove bicycle lanes from the road map for instance. Dissolving very small features into less small features might also help for the buildings by aggregating them into building blocks for instance. However, don;t do this on roads and rivers, because your spatial index won't work anymore slowing down instead. another option is to look at tiles and to do the rendering only one time for these tiles. There is some tiling stuff in SharpMap, but I haven't looked at it yet. Splitting the datasets into smaller ones on attirbute data might also help. From a road network shapefile, you create a shapefile with the highways, one with the primary roads, one with the secondary roads etc. By setting the minimum or maximum visibility level (not sure which one it is, haven't got my VS here ) you can avoid rendering high scale data at very low scales. You want the highways to be rendered at national level, but not the local roads. To do so, you set this level at the local road so that it only renders at high scale. Combine this with a spatial index on all shapefiles I mentioned earlier. Hope there is something usefull for you in here.