Problem with WMS demo in V2.0

Topics: SharpMap v2.0
Aug 3, 2009 at 7:55 PM

Hi, I'm trying to get the WMS server demo in SharpMap.Demo.AspNet working but I'm having some troubles.

1. I couldn't restore the database backup data in a my instance of SQL Server 2008 Express, so I changed the DemoMapSetupUtility file to setup the map using the SHP provider instead of MsSqlSpatial.

2. The BCRoads shapefile in App_Data is missing the .DBF, in this scenario I get this exception (in the global exception handler of AsyncWmsHandlerBase.cs)

System.NullReferenceException was caught
  Message="Referencia a objeto no establecida como instancia de un objeto."
  Source="SharpMap"
  StackTrace:
       en SharpMap.Map.onSpatialReferenceChanged() en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Map.cs:línea 1058
       en SharpMap.Map.set_SpatialReference(ICoordinateSystem value) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Map.cs:línea 1014
       en SharpMap.Presentation.AspNet.WmsServer.WmsMapRequestConfig.ConfigureMap(Map map) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\WmsServer\WmsMapRequestConfig.cs:línea 56
       en SharpMap.Presentation.AspNet.Handlers.MapHandlerBase.ConfigureMap() en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\Handlers\MapHandlerBase.cs:línea 334
       en SharpMap.Presentation.AspNet.WmsServer.AsyncWmsHandlerBase.Render(String& mimeType) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\WmsServer\AsyncWmsHandlerBase.cs:línea 65
  InnerException:

3. When I copy the files from $\TestData\bcroads.* (including the .dbf) into $\Demos\WebSite\App_Data\Shapefiles then I get this exception:

System.NullReferenceException was caught
  Message="Referencia a objeto no establecida como instancia de un objeto."
  Source="SharpMap"
  StackTrace:
       en SharpMap.Data.Providers.AsyncResult.EndInvoke() en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Data\Providers\AsyncResult.cs:línea 104
       en SharpMap.Data.Providers.AsyncResult`1.EndInvoke() en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Data\Providers\AsyncResult`1.cs:línea 38
       en SharpMap.Data.Providers.AsyncFeatureProviderAdapter.EndExecuteQuery(IAsyncResult asyncResult) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Data\Providers\AsyncFeatureProviderAdapter.cs:línea 69
       en SharpMap.Layers.Layer.LoadLayerData(QueryExpression query) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Layers\Layer.cs:línea 583
       en SharpMap.Layers.FeatureLayer.handleFeaturesSelectRequested(Object sender, SelectRequestedEventArgs e) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Layers\FeatureLayer.cs:línea 321
       en SharpMap.Data.FeatureDataTable.OnSelectRequested(FeatureQueryExpression query) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Data\FeatureDataTable.cs:línea 823
       en SharpMap.Data.FeatureDataTable.<Select>d__6.MoveNext() en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Data\FeatureDataTable.cs:línea 687
       en SharpMap.Presentation.AspNet.MVP.MapPresenter.<EnumerateWhileMonitoringClientConnection>d__0`1.MoveNext() en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\MVP\MapPresenter.cs:línea 170
       en SharpMap.Presentation.AspNet.MVP.MapPresenter.RenderFeatureLayer(IFeatureLayer layer, RenderPhase phase) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\MVP\MapPresenter.cs:línea 195
       en SharpMap.Presentation.Presenters.MapPresenter2D.RenderLayer(ILayer layer, RenderPhase phase) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Presentation\Presenters\MapPresenter2D.cs:línea 981
       en SharpMap.Presentation.Presenters.MapPresenter2D.RenderAllLayers(RenderPhase phase) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Presentation\Presenters\MapPresenter2D.cs:línea 948
       en SharpMap.Presentation.Presenters.MapPresenter2D.RenderAllLayers() en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Presentation\Presenters\MapPresenter2D.cs:línea 925
       en SharpMap.Presentation.Presenters.MapPresenter2D.setViewMetricsInternal(Size2D newViewSize, ICoordinate newCenter, Double newWorldWidth) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Presentation\Presenters\MapPresenter2D.cs:línea 1499
       en SharpMap.Presentation.Presenters.MapPresenter2D.setViewEnvelopeInternal(IExtents2D newEnvelope) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Presentation\Presenters\MapPresenter2D.cs:línea 1416
       en SharpMap.Presentation.Presenters.MapPresenter2D.ZoomToWorldBoundsInternal(IExtents2D zoomBox) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Presentation\Presenters\MapPresenter2D.cs:línea 705
       en SharpMap.Presentation.Presenters.MapPresenter2D.handleViewZoomToWorldBoundsRequested(Object sender, MapViewPropertyChangeEventArgs`1 e) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap\Presentation\Presenters\MapPresenter2D.cs:línea 1262
       en SharpMap.Presentation.AspNet.MVP.WebMapView.onRequestZoomToWorldBounds(IExtents2D zoomBox) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\MVP\WebMapView.cs:línea 430
       en SharpMap.Presentation.AspNet.MVP.WebMapView.ZoomToWorldBounds(IExtents2D zoomBox) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\MVP\WebMapView.cs:línea 264
       en SharpMap.Presentation.AspNet.WmsServer.WmsMapRequestConfig.ConfigureMapView(IMapView2D mapView) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\WmsServer\WmsMapRequestConfig.cs:línea 76
       en SharpMap.Presentation.AspNet.Handlers.MapHandlerBase.ConfigureMapView() en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\Handlers\MapHandlerBase.cs:línea 220
       en SharpMap.Presentation.AspNet.WmsServer.AsyncWmsHandlerBase.Render(String& mimeType) en D:\Dev\OpenSource\SharpMap\sharpmap\SharpMap.Presentation\AspNet\WmsServer\AsyncWmsHandlerBase.cs:línea 85
  InnerException:

 

The request that I'm issuing to the server is this:

http://localhost:50476/Maps/wms.ashx?REQUEST=GetMap&Layers=BCRoads&STYLES=&CRS=EPSG:4326&BBOX=-180,-90,180,90&WIDTH=600&HEIGHT=300&FORMAT=image/png&VERSION=1.3.0

 

Any help in making this work will be very appreciated.

Regards.

Coordinator
Aug 4, 2009 at 7:41 PM

Hi gschuager, I have updated the setupShapefile method and also fixed an issue with ConcatenatedTransform in ProjNet get latest and it should run

use 

http://localhost:50476/Maps/wms.ashx?REQUEST=GetMap&Layers=Countries,Rivers,Cities&STYLES=&CRS=EPSG:4326&BBOX=-180,-90,180,90&WIDTH=600&HEIGHT=300&FORMAT=image/png&VERSION=1.3.0

be aware though that the shapefile provider is not a good choice for web as it locks the files on disk and can cause access violation exceptions (It needs to do this to allow the provider to be writable) this will be particularly troublesome in a tiled environment

 hth jd

Aug 5, 2009 at 9:02 PM

Thank you johndiss.

It is working fine now.

I'm just experimenting with the library. I plan to use the SQL2008 provider later.

Regards.

Aug 6, 2009 at 1:58 PM

Hi again,

I'm facing other issues now...

I'm trying to get a WMS server (using SM) to work with a WPF client (heavily) based on the BruTile project (http://www.codeplex.com/brutile)

1. Since the tiling client issues simultaneous requests I've got into the locking problem with the shape-file provider... so,

2. I've loaded the shapefiles into an SQL Server 2008 Express database and configured the setup/provider accordingly in the WMS server (I've used this http://www.sharpgis.net/page/SQL-Server-2008-Spatial-Tools.aspx). Since I can query the data and render it into SQL Server Management Studio I assume that it is imported correctly.

3. If I do a manual request, the map is rendered ok (I've disabled caching from the WMS server)

4. If I let my WPF client to request the tiles by itself, they are rendered wrong (the map seems like a puzzle) and some of them are plain empty.

5. If I change the WMS server implementation to one using SM 0.9, then it works perfectly.

I'm a bit lost at this point and would appreciate some help.

If more information is needed I will be glad to provide it (sample application, screenshot of the scrambled map, log of the requests issued, etc.)

Regards,

Germán.

Coordinator
Aug 6, 2009 at 3:03 PM

Hi again, to be honest for the wms server to be effective we need to move away from GDI+ - there are far too many issues associated with it, this work is ongoing but is not ready yet.

Not sure why your tiles should be puzzle like - perhaps tiles are showing their previous content when a new request has bombed?

Also there is a demo project "FormatConverter" which you can use to import data into sql (and other things) - make sure you build it at least twice before running (macros need to run to copy files around).

hth jd