Labeling line strings (streets)

Topics: General Topics
Sep 15, 2009 at 11:07 PM

I have a shape layer that contains street information as line strings. I can draw the layer in sharpMap however, trying to figure out how to label the street names. Any help is appreciated.

Sep 15, 2009 at 11:18 PM

Hi oneonefive, use a LabelLayer and assign the same datasource as the matching vector layer. Use the LabelColumn if the desired text is aleady in the dataset or LabelStringDelegate if you need to calculate or concat data. hth jd

Sep 16, 2009 at 12:13 PM

Hi Johndiss, thanks for the reply. I am very new at this. Would you happen to have a few line of codes to get me started?

Thank you.

Sep 16, 2009 at 12:47 PM

Have a look at and replace the postgis provider with whichever one you are using

cheers jd

Sep 16, 2009 at 1:02 PM

Awesome. Thanks so much.

Sep 16, 2009 at 1:27 PM

John, can I bug u with one more Q? I have been using SharpMap.Data.Providers.Katmai to pull data from SQL 08. This provider (belive written by you in 08) uses geometry as the datatype and I have been converting the code to use geography. Is there a newer/better provider now for SQL 08 and that uses geography data?

I was wrong, one more. How would I display only partial data based on a SQL query in a layer? For example, I only want to show the streets that are within a given boundary (ex. community).

Thanks for all your help.

Sep 16, 2009 at 1:36 PM

Actually it was written by Bill Dollins (I wrote the one for V2). I have recently imported Bills Katmai provider into the source tree but renamed as SqlServer2008.

SqlGeography is based on a spherical coordinate system - Sharpmap is based on a planar coordinate system - you will need to convert the geometries.

You will need to add that functionality to the provider - if you have a look at the provider for MsSqlSpatial you should get some hints - see DefinitionQuery property

hth jd

Sep 16, 2009 at 1:48 PM

Thanks (and you too Bill).

I have been displaying the geography data using sharpmap and some code conversion like the following. Are you saying this scheme will produce incorrect result? BTW, my windows maps using sharpmap look identical to the web map using bing map.

//string whereClause = this.GeometryColumn + ".STIntersects(geometry::STGeomFromText('" + bboxText + "', " + this.SRID.ToString() + ")) = 1";

<font size="2" color="#008000"><font size="2" color="#008000">


</font></font><font size="2" color="#008000">



string whereClause = this.GeometryColumn + ".STIntersects(geography::STGeomFromText('" + bboxText + "', " + this.SRID.ToString() + ")) = 1";


<font size="2" color="#008000"><font size="2" color="#008000">

//string strSQL = "SELECT g.*, g." + this.GeometryColumn + ".Get_WKB() AS sharpmap_tempgeometry ";

</font></font><font size="2" color="#008000">




string strSQL = "SELECT g.*, g." + this.GeometryColumn + ".STAsBinary() AS sharpmap_tempgeometry ";

Sep 16, 2009 at 2:25 PM
Edited Sep 16, 2009 at 2:26 PM

if it works it works ;)

Thinking about it a bit more perhaps it should work as [To|From][Wkb|Wkt] will always be the same regardless of how it is stored.. hmm