This project has moved. For the latest updates, please go here.

Editing in map that connected to PostGIS

Topics: SharpMap v2.0
Jul 7, 2009 at 2:44 PM
Edited Jul 7, 2009 at 2:51 PM

Hi all

private void btnShowMap_Click(object sender, EventArgs e)



            myMap.BackColor = Color.White; //Set background

            myMap.Size = mapImage1.Size;

            SharpMap.Layers.VectorLayer postGISLayer = new SharpMap.Layers.VectorLayer("nile");


            string ConnStr = "Server=;Port=5432;User Id=postgres;Password=password;Database=postgis;";

            postGISLayer.DataSource = new SharpMap.Data.Providers.PostGIS(ConnStr, "nile", "oid");





            mapImage1.Image = myMap.GetMap();



I show map from PostGIS successfully by using the prev method.

Now,I want to enable user to make editing in map then it automatic modified in the source which is PostGIS

Can anyont help me?

Mohammed Thabet Zaky Mohammed

GIS Developer



Jul 7, 2009 at 3:07 PM

Hi Mohammed, in 0.9 all the providers are readonly, however you could implement it fairly easily.. I would suggest starting by:

subclassing the PostGIS or PostGIS2 provider
adding a method which takes either a FeatureDataTable or IEnumerable<FeatureDataRow> and
builds and caches a parameterized update statement (perhaps with a CommandBuilder)
loops through each item in the input updating the parameters and executing the statement

hth jd