Re: [mapserver-users] MapServer 7.4.3 - Poor projection from British National Grid (EPSG 27700) to WebMercator (EPSG 3857)

2021-09-06 Thread Mike Saunt
Ben

Have you considered using PostGIS to do the transformation instead?  Also,
depending on the amount of data you could set up some material views
building transformed data or similar which may make it more responsive, if
that is needed.

All the best
Mike


On Mon, 6 Sept 2021 at 11:52,  wrote:

> Reposted from
> https://gis.stackexchange.com/questions/410874/mapserver-7-4-3-poor-projection-from-british-national-grid-epsg-27700-to-web
>
> We have PostGIS data in BNG and are displaying it over Google satellite
> imagery.
>
> This worked fine previously - using a Ubuntu server running 18.04, with
> MapServer 7.0.7, GDAL 2.2.3, proj 4.9.3.
>
> This server is long out of date and we have a new one running 20.02, with
> MapServer 7.4.3, GDAL 3.0.4 and proj 6.3.1. However this is projecting the
> BNG layers incorrectly (~200m ESE).
>
> This appears to be similar to the issue reported at
> https://github.com/OSGeo/gdal/issues/3695 although that claims the
> problem only arose after proj 7.2.1
>
> I have installed the updated transform OSTN15_NTv2_OSGBtoETRS.gsb but this
> had no effect.
>
> Is there a way to update the transforms used by MapServer or get MapServer
> to pass the transformation to PostGIS ?
>
> Thanks
>
> Ben
> ___
> MapServer-users mailing list
> MapServer-users@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>
___
MapServer-users mailing list
MapServer-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users


[mapserver-users] MapServer 7.4.3 - Poor projection from British National Grid (EPSG 27700) to WebMercator (EPSG 3857)

2021-09-06 Thread mapserver
Reposted from 
https://gis.stackexchange.com/questions/410874/mapserver-7-4-3-poor-projection-from-british-national-grid-epsg-27700-to-web


We have PostGIS data in BNG and are displaying it over Google satellite 
imagery.


This worked fine previously - using a Ubuntu server running 18.04, with 
MapServer 7.0.7, GDAL 2.2.3, proj 4.9.3.


This server is long out of date and we have a new one running 20.02, 
with MapServer 7.4.3, GDAL 3.0.4 and proj 6.3.1. However this is 
projecting the BNG layers incorrectly (~200m ESE).


This appears to be similar to the issue reported at 
https://github.com/OSGeo/gdal/issues/3695 
 although that claims the 
problem only arose after proj 7.2.1


I have installed the updated transform OSTN15_NTv2_OSGBtoETRS.gsb but 
this had no effect.


Is there a way to update the transforms used by MapServer or get 
MapServer to pass the transformation to PostGIS ?


Thanks

Ben

___
MapServer-users mailing list
MapServer-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users


[mapserver-users] Potential bug when using Layer-Tile-Index where indexed files are GeoTiff files

2021-09-06 Thread Sommer, Ashley (L, Dutton Park)
Hi Everyone,
I'm trying to get WCS service with TIME parameter support working on latest 
Mapserver.
My data is a timeseries of large geotiff files, in a directory, with the date 
encoded in the filename.
Eg:
 - /datasets/mydataset/v1/layer1/raster_2020-08-01.tif
 - /datasets/mydataset/v1/layer1/raster_2020-08-02.tif
 - etc.
I'm had it working on the WMS side of things, simply using Runtime 
Substitution, and embedding the TIME parameter into the DATA directive.
eg:
  DATA "/datasets/mydataset/v1/layer1/raster_%time%.tif"
That worked for WMS, but not for WCS. When Mapserver's WCS service encounters a 
TIME parameter, it assumes I'm using a tile index. If there is no tile index, 
it errors out.

So I create a tile index for this dataset. Using gdaltindex for a record of 
"location" for each raster, then adding a temporal attribute to the dbf file, 
and assigning dates to each of the records.
I then tried to use that in place of DATA:
LAYER
  NAME "mylayer"
  TILEINDEX "/datasets/mydataset/v1/layer1/index.shp"
  TILEITEM "location"
END
Unfortunately, that doesn't work, because Mapserver now requires the use of 
new-style Layer-Tile-Index directives in order for WCS to work properly.
So I changed it to:
LAYER
  NAME "MyIndex"
  TILEINDEX "/datasets/mydataset/v1/layer1/index.shp"
  TILEITEM "location"
END
LAYER
  TILEINDEX "MyIndex"
  TILEITEM "location"
END

This now works to some extent, but then I get an error:
msTiledSHPTryOpen(): Unable to access file. Unable to open shapefile 
'raster_2020-08-02.tif' for layer 'MyIndex' ... fatal error. msShapefileOpen(): 
Unable to access file. (/tmp/raster_2020-08-02.tif) msShapefileOpen(): Unable 
to access file. (/datasets/mydataset/v1/layer1/raster_2020-08-01.tif)

I believe I have tracked down why this is happening, and I believe it is a bug.
1) Mapserver _can_ open the .shp and .dbf file at the location. It must be able 
to to get the file location from the dbf index.
2) msTiledSHPTryOpen() is a helper fn that runs _after_ opening a tile index, 
to test if we can open the first-indexed file (to template some parts of the 
layer).
See comment here: 
https://github.com/MapServer/MapServer/blob/0d156a72893b1df712cb49c1b3ddaeed5365a68b/mapshape.c#L2028
See also msTileSHPTryOpen fn here: 
https://github.com/MapServer/MapServer/blob/0d156a72893b1df712cb49c1b3ddaeed5365a68b/mapshape.c#L1868
3) So msTiledSHPTryOpen() tries to open the first-indexed file: 
"/datasets/mydataset/v1/layer1/raster_2020-08-02.tif" but returns an error, 
even though it _can_ open that file.
The problem is, it is using msShapefileOpen() to do this, which in-turn uses 
msSHPOpen() to open the tif file:
See msShapefileOpen fn: 
https://github.com/MapServer/MapServer/blob/0d156a72893b1df712cb49c1b3ddaeed5365a68b/mapshape.c#L1665
See opener: 
https://github.com/MapServer/MapServer/blob/0d156a72893b1df712cb49c1b3ddaeed5365a68b/mapshape.c#L1686
4) msSHPOpen() assumes whatever file its opening will have a .shp file and a 
.shx file.
In this case, it's trying to open a .tif file. The function tries to open a 
non-existent /datasets/mydataset/v1/layer1/raster_2020-08-02.shp file.
See the implementation here: 
https://github.com/MapServer/MapServer/blob/0d156a72893b1df712cb49c1b3ddaeed5365a68b/mapshape.c#L194
And where it opens a file here: 
https://github.com/MapServer/MapServer/blob/0d156a72893b1df712cb49c1b3ddaeed5365a68b/mapshape.c#L252

So I believe it is a bug to use msShapefileOpen() to test if a tileindex can 
open a file at its first-indexed location, because that file may not be a .shp 
file.

I might be able to put in a PR to fix the bug, but I don't know the codebase 
well enough to not potentially introduce regressions.
Let me know what you think?

- Ashley Sommer
___
MapServer-users mailing list
MapServer-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users