map rendering

Topics: General Topics, SharpMap v0.9 / v1.x
Oct 11, 2011 at 5:48 PM

Hi,

I have a lot of geometries on the map, so it's rendering slowly.

I'm thinking is there a way to render invalidation part only of the whole map when I'm using a pan tool to move the map.

What I mean is when I zoom to a particular zoom of the map. The part of map that I move out of screen will still exist. So next time I move to this part, I do not need to render it again and that will improve the speed.

I think google map is using this tech. I'm using SharpMap 0.9 Mapbox samples

Thanks.

Developer
Oct 12, 2011 at 6:00 AM
Edited Oct 12, 2011 at 6:01 AM

Hi,

Google's map and some webmap use title cache for rendering images of map.

SharpMap can also save title cache. Pleased view: http://sharpmap.codeplex.com/workitem/31495.

Now, SharpMap haven't created cached layer but you can save title layer ( above) and use titlelayer class on sharpmap for cache layer

 

TrieuVy.

Oct 12, 2011 at 11:59 AM

Hello,

I've tried to use a cache and that improve a lot the rending (during zooming, ranning,...) it's about 3 or 4 times faster, depends on, of course, of the layer. I made the test on 30 000 geoms.

I used this code in SQLServer2008.cs

     Collection<Geometry> _features = new Collection<Geometry>();
        Collection<BoundingBox> _fBB = new Collection<BoundingBox>();
        /// <summary>  
        /// Returns geometries within the specified bounding box  
        /// </summary>  
        /// <param name="bbox"></param>  
        /// <returns></returns>  
        public Collection<Geometry> GetGeometriesInView(BoundingBox bbox)
        {
           -----if the datas already loaded
         if (_features.Count > 0)
           {
               Collection<Geometry>  featuresBB = new Collection<Geometry>();
 
                for (int i = 0; i < _features.Count; i++)
             {
                if (_fBB[i].Intersects(bbox))
                  {
                     featuresBB.Add(_features[i]);
                  }
            }
                return featuresBB;
            }

-------- Loading geom from database -> the first time

 
                                 Geometry geom = Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr[0]);
                                 if (geom != null)
                                 {
                                     _features.Add(geom);
                                     _fBB.Add(geom.GetBoundingBox());

------ return the feature

It's not realy optimising and shouldn't use like this in a real application (I done this code only for test).

 

@TrieuVy: Tile layer is for raster layaer , isn't it ? Is is possible to use Tile layers on vectors ?

Eric

Developer
Oct 13, 2011 at 2:34 AM

Hi Eric,

we can create title layer from vector layers . Follow me title layer is static vector layers. Title layer is good when you only use to show map ( read only ).

sharp map have both title layer and vevtor layer. We can add a lot of layers in Sharmap

TrieuVy.

Oct 13, 2011 at 12:22 PM

Hi, trieuvy

Thanks a lot,  I will try it.

And can I use this method to cache the the google map background so that when I am offline I still can use google map images

Developer
Oct 14, 2011 at 3:01 AM
Edited Oct 14, 2011 at 3:07 AM

Hi,

Check committed version 93263 http://sharpmap.codeplex.com/SourceControl/changeset/changes/93263  added support cached files title layer

TrieuVy