New version RC2

Topics: SharpMap v0.9 / v1.x
Apr 19, 2013 at 7:12 PM
I downloaded and installed RC2 and my working project broke. Here is the code that worked on 0.9.
Dim provider As SharpMap.Data.Providers.PostGIS
    Dim SiteLayer As SharpMap.Layers.VectorLayer = New SharpMap.Layers.VectorLayer("Site Layer")
    provider = New SharpMap.Data.Providers.PostGIS(poolConnection, "sites", "lonlat_nad83", "pk_sites")
    provider.DefinitionQuery = "jobnumber = '" & JobNumber & "'"
    SiteLayer.DataSource = provider

    With SiteLayer.Style
        .PointSymbolizer = SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateCircle(New Pen(Drawing.Color.Green, 2.0), Brushes.Black, 10)
    End With
    MapBox1.Map.Layers.Add(SiteLayer)
MapBox1.Map.ZoomToExtents()
    MapBox1.Map.Zoom *= 1.2
Also, what is the replacement for SharpMap.Geometry.Point? GeoAPI has no replacement.
Coordinator
Apr 19, 2013 at 7:23 PM
What error do you get?

NetTopologySuite.Geometries.Point is the replacement (That implements GeoAPI.Geometries.IPoint)
Apr 19, 2013 at 7:46 PM
No error, but no map
Apr 19, 2013 at 7:53 PM
If I use NetTopologySuite.Geometries.Point , I get this error:

Error 2 Method 'Private Sub MapBox1_MouseMove(worldPos As NetTopologySuite.Geometries.Point, imagePos As System.Windows.Forms.MouseEventArgs)' cannot handle event 'Public Event MouseMove(worldPos As GeoAPI.Geometries.Coordinate, imagePos As System.Windows.Forms.MouseEventArgs)' because they do not have a compatible signature. D:\Documents and Settings\slhall\My Documents\Visual Studio 2010\Projects\TSE\TSE\FrmMain.vb 413 147 TSE
Coordinator
Apr 20, 2013 at 10:13 AM
Point is the GeometryType (similar to LineString, Polygon). Some methods however use the unserlying Coordinate directly (GeoAPI.Geometries.Coordinate) like the MouseMove event..

So your definition should be
'Private Sub MapBox1_MouseMove(worldPos As GeoAPI.Geometries.Coordinate, imagePos As System.Windows.Forms.MouseEventArgs)
Apr 21, 2013 at 10:10 PM
I still can't get PostgreSQL data to work with version 1.0 RC2. The following code worked fine with 0.9, The shapefile works OK, but if I try to add either of the Postgres layers the mapbox goes blank
 Private Sub B_loadMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_loadMap.Click
        Logger.Trace("Loading map")
        MapBox1.Map.Layers.Clear()
        MapBox1.WheelZoomMagnitude = MapBox1.WheelZoomMagnitude * -1  ' this reverses the direction of the mouse wheel zoom to match Google

        vlay = New SharpMap.Layers.VectorLayer("States")
        vlay.DataSource = New SharpMap.Data.Providers.ShapeFile("D:\Documents and Settings\slhall\My Documents\Map Data\shp\usa_state_shapefile.shp", True)
         MapBox1.Map.Layers.Add(vlay)


        ' Add PostGIS site layer:
        Dim provider As SharpMap.Data.Providers.PostGIS
        SiteLayer = New SharpMap.Layers.VectorLayer("Site Layer")
        provider = New SharpMap.Data.Providers.PostGIS(poolConnection, "sites", "lonlat_nad83", "pk_sites")
        provider.DefinitionQuery = "jobnumber = '" & JobNumber & "'"
        SiteLayer.DataSource = provider
          MapBox1.Map.Layers.Add(SiteLayer)

           PathLayer = New SharpMap.Layers.VectorLayer("Path Layer")
        Dim pathProvider As New SharpMap.Data.Providers.PostGIS(poolConnection, "paths", "path", "pk_paths")
        pathProvider.DefinitionQuery = "jobnumber = '" & JobNumber & "'"
        PathLayer.DataSource = pathProvider
        MapBox1.Map.Layers.Add(PathLayer)

        MapBox1.Map.ZoomToExtents()

        MapBox1.Map.Zoom *= 1.2
        MapBox1.Refresh()
        '  MapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan
    End Sub
Coordinator
Apr 22, 2013 at 6:59 AM
I just had a brief look at the SharMap.Extensions Zip file offered for download. It may be lacking NetTopologySuite.IO project.
You can easily fix that using the nuget package manager by typing
Install-Package NetTopologySuite.IO

We'll fix the Zip-File though, too.

Hth FObermaier
Apr 22, 2013 at 12:22 PM
That works!! Thank you very much.