Refresh the SharpMap to Posatgis connection

Feb 3, 2009 at 9:11 PM


I'm using FileSystemWatcher to attempt control of the Postgis layers in SharpMap.

Can anyone suggest a procedure for refreshing theconnection.

I have the Watcher working, I'm just stuck on getting the DefinitionQuery to refresh.

RefreshMap(); doesn't do the job.

Any suggestions would be appreciated.

 SharpMap.Data.Providers.PostGIS provider = new SharpMap.Data.Providers.PostGIS(ConnStr, "p_id.p_id", "the_geom", "public");//create a new provider
provider.DefinitionQuery = "P_ID.P_ID.P_ID_ID=" + "'" + filecontents + "'"; //configure the definitionQuery
myLayer.DataSource = provider; //assign the provider to the layer


Feb 3, 2009 at 9:42 PM
Hi Bob, are you sure that the filecontents variable is being updated prior to refreshing the map? cheers jd
Feb 3, 2009 at 10:13 PM

Hi John

I think so.

I put a Show Message just prior to RefreshMap and the message does show for both Change and Create.

Here is the code for the RefreshMap -

  private void RefreshMap()
//--> Use SharpMap to generate the map image
picMap.Image = _sharpMap.GetMap();

I suspect it is just refreshing the Image.

If so,I need a code to refresh ( or recreate) the QueryDefinition??


Feb 3, 2009 at 10:18 PM
Right - from your example above it is not clear how the filecontents variable is created. You need it to be completely reset when the FileSystemWatcher fires and for the change to be propegated to the PostGis provider. Try setting a breakpoint just before Map.GetMap is called and make sure that the definition query on the provider is what you expect.. cheers jd