geotrellis / geotrellis-server

Tools for building raster processing and display services
Apache License 2.0
73 stars 24 forks source link

Problem with utm projections #304

Closed Marc-AndreDaviault closed 3 years ago

Marc-AndreDaviault commented 4 years ago

I found a problem with UTM projections like EPSG 2957. That getmap : https://datacube.services.geo.ca/ows/elevation?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-13545.86242142471019,6808610.873036045581,1090481.44127773121,7675087.328320214525&CRS=EPSG:2957&WIDTH=1135&HEIGHT=890&LAYERS=hrdsm&STYLES=elevation&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE

Creates this error: java.lang.IllegalArgumentException: Encountered NaN during a refinement step: (NaN / NaN). Input Extent(-1660601.1799640926, 6234591.702313175, 2781860.5915472955, 9774981.542054784) is likely not in source projection.

You can test it with the same service: https://datacube.services.geo.ca/ows/elevation?service=wms&request=GetCapabilities

Marc-AndreDaviault commented 3 years ago

I made two services to help solve this problem.

The problem only occurs with the elevation service. Maybe the problem is related to the discontinuous coverage of the data because it works well with the Landcover service. It’s not working for either wgs84, Nad83 and nad83 csrs.

Get capabilities elevation : https://datacube-stage.services.geo.ca/ows/elevation?service=wms&request=GetCapabilities

wgs84 / UTM zone 7N (EPSG:32607) https://datacube-stage.services.geo.ca/ows/elevation?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-2551963.44201122364,4120299.072914671618,7434090.527404137887,14354099.21856410615&CRS=EPSG:32607&WIDTH=791&HEIGHT=810&LAYERS=dsm-hillshade&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE

NAD83 / UTM zone 7N (EPSG:26907) https://datacube-stage.services.geo.ca/ows/elevation?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-2551963.442031255923,4120299.072805030271,7434090.527400341816,14354099.21848984994&CRS=EPSG:26907&WIDTH=791&HEIGHT=810&LAYERS=dsm-hillshade&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE

NAD83(CSRS) / UTM zone 7N (EPSG:3154) https://datacube-stage.services.geo.ca/ows/elevation?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-2551963.442031255923,4120299.072805030271,7434090.527400341816,14354099.21848984994&CRS=EPSG:3154&WIDTH=791&HEIGHT=810&LAYERS=dsm-hillshade&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE

Get capabilities Landcover : https://datacube-stage.services.geo.ca/ows/landcover?service=wms&request=GetCapabilities

wgs84 / UTM zone 7N (EPSG:32607)Is working https://datacube-stage.services.geo.ca/ows/landcover?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-2913196.281835428439,3795692.309206086211,7988972.614486393519,14883308.68939520605&CRS=EPSG:32607&WIDTH=797&HEIGHT=810&LAYERS=2015&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE

NAD83 / UTM zone 7N (EPSG:26907)Is working https://datacube-stage.services.geo.ca/ows/landcover?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-2913196.281855762471,3795692.309101689607,7988972.614462190308,14883308.68931791373&CRS=EPSG:26907&WIDTH=797&HEIGHT=810&LAYERS=2015&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE

NAD83(CSRS) / UTM zone 7N (EPSG:3154)Is working https://datacube-stage.services.geo.ca/ows/landcover?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-2913196.281855762471,3795692.309101689607,7988972.614462190308,14883308.68931791373&CRS=EPSG:3154&WIDTH=797&HEIGHT=810&LAYERS=2015&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE

pomadchin commented 3 years ago

This bug let me into the proj4j land, and resulted in this PR https://github.com/locationtech/proj4j/pull/71/files#diff-a275e7d2e276276ca789fe5524f046c60949780ac2b43c451c8ff5f83eac53bbR274

I'm verifying now that it resolves the issue.

pomadchin commented 3 years ago

I can confirm that this issue is fixed in https://github.com/locationtech/proj4j/pull/71

pomadchin commented 3 years ago

Will keep this task as a place holder, and will close it once we'll upgrade dep up to date.

pomadchin commented 3 years ago

For tests I used the following query:

http://localhost:9000/?service=WMS&request=GetMap&BBOX=-13545.86242142471019,6808610.873036045581,1090481.44127773121,7675087.328320214525&CRS=EPSG:2957&WIDTH=1135&HEIGHT=890&LAYERS=hrdsm&STYLES=elevation&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE

That is the debug branch https://github.com/geotrellis/geotrellis-server/tree/fix/utm (contains mock GeoTrellisRasterSources to generate emty outputs on requests).