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

Custom query postgis database

Topics: Algorithms
Apr 25, 2012 at 5:10 AM
Edited Apr 25, 2012 at 5:10 AM

Hi All!

I have the code to load the map from PostGIS database:

SharpMap.Layers.VectorLayer layGiaoThong = new SharpMap.Layers.VectorLayer("p3_h_giaothong");            
            layGiaoThong.DataSource = new SharpMap.Data.Providers.PostGIS(PostGisConnectionString, "p3_h_giaothong", "the_geom", "gid");
            //Define a blue 1px wide pen
            layGiaoThong.Style.Line = new System.Drawing.Pen(System.Drawing.Color.Blue, 1);
it will load all data from table p3_h_giaothong but I want to load only part of the table data, help me!!!
Apr 25, 2012 at 7:10 AM
Edited Apr 25, 2012 at 8:19 AM

you can place an additional "WHERE" constraint to the DefinitionQuery property.

e.g. if you only want those that have values 'A', 'B' or 'C' in column "class" you need to add (object initialization)

{ DefinitionQuery = "\"class\" IN ('A', 'B', 'C')" }

to your new PostGIS constructor call.

Hth FObermaier

Apr 25, 2012 at 8:03 AM

Thanks a lot.