Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proj error on recent master image #822

Open
pvgenuchten opened this issue Jun 14, 2024 · 13 comments
Open

proj error on recent master image #822

pvgenuchten opened this issue Jun 14, 2024 · 13 comments

Comments

@pvgenuchten
Copy link

the latest master image gives me problems with projections, something changed in image build (or mapserver)?

    PROJECTION
        "EPSG:4326"
    END

msProcessProjection(): Projection library error. proj error "Invalid PROJ string syntax" for "EPSG:4326"

also tried init=epsg:4326

the master image of last month works fine...

@pvgenuchten
Copy link
Author

pvgenuchten commented Jun 14, 2024

@geographika indicates it may be related to moving from proj_lib env to proj_data env, based on version of proj

see https://proj.org/en/9.4/usage/environmentvars.html

I added an env param PROJ_DATA, but it has no effect

proj --version
Rel. 9.4.0, March 1st, 2024

@pvgenuchten
Copy link
Author

pvgenuchten commented Jun 14, 2024

Ok, we found the problem, I'm used to starting my mapfiles with

CONFIG 'PROJ_LIB' '/usr/share/proj/'

With the new version of proj this is problematic, and causes above error.
Because proj resources are on a default location, you can however remove the config line, and all works fine

@geographika
Copy link
Contributor

geographika commented Jun 14, 2024

I can recreate the error by setting the following in a Mapfile in the master Docker image (before any PROJECTION blocks):

CONFIG "PROJ_DATA" "/usr/share/proj/"

I get msProcessProjection(): Projection library error. proj error "Invalid PROJ string syntax" for "init=epsg:4326"

If I set it to the following it runs fine:

CONFIG "PROJ_DATA" "/usr/local/share/proj/"

The base image at https://github.com/OSGeo/gdal/blob/master/docker/ubuntu-small/Dockerfile builds PROJ so I'm not sure why there is a difference.
It does download grids from http://download.osgeo.org/proj/proj-datumgrid-latest.zip and puts them in the image - maybe these are incompatible with the PROJ version?

(Probably unrelated) - I don't fully understand the symlink here:

&& ln -s /usr/local/lib/libproj.so.25 /usr/local/lib/libproj.so
- is this tied to a specific PROJ version?

@pvgenuchten
Copy link
Author

@sbrunner @geographika I closed as completed, but maybe we should reopen to facilitate more research or documentation

@pvgenuchten pvgenuchten reopened this Jun 14, 2024
@geographika
Copy link
Contributor

The GDAL base image builds the master version of PROJ from whenever it is tagged (ARG PROJ_VERSION=master). The MapServer Docker image uses ubuntu-small-3.8.5 as gdal as the base image, so the version of PROJ used is whatever is in master at this point in time. The corresponding PROJ DATA files are installed to /usr/local/share/proj/ (ARG PROJ_INSTALL_PREFIX=/usr/local).

I'm not sure, but I'm guessing another version of PROJ is installed onto the image.
https://github.com/camptocamp/docker-mapserver/blob/master/ci/dpkg-versions.yaml has ubuntu_22_04/libproj22: 8.2.1-1 listed - maybe this is a dependency of something else? I think this installs to /usr/share/proj/ but doesn't match the PROJ version causing the error.

@sbrunner
Copy link
Member

Shouldn't we simply add the environment variable PROJ_DATA in the Dockerfile:

ENV PROJ_DATA=/usr/share/proj/

@pvgenuchten
Copy link
Author

I tried a env param proj_data, no effect, either gets overwritten by the config in mapfile or there is a problem with the path; usr/share/proj vs usr/local/share/proj

@sbrunner
Copy link
Member

I don't fully understand the symlink here:
...

This is just to make the build work

@geographika
Copy link
Contributor

Shouldn't we simply add the environment variable PROJ_DATA in the Dockerfile:

ENV PROJ_DATA=/usr/share/proj/

Assuming the PROJ install in pkg-versions.yaml is required, then I think updating the sample in mapserver.conf is enough (note the working value is /usr/local/share/proj/). The container is working fine for me without having to set PROJ_DATA (or PROJ_LIB) (I presume it defaults to the correct location?).

@pvgenuchten - a PROJ_DATA setting in a Mapfile will always take precedence over any environment setting or setting in mapserver.conf - I'd suggest removing these and if a custom path is needed setting it in mapserver.conf.

Note, from MapServer/MapServer#6573 on the deprecation plan for PROJ_LIB:

PROJ 9.1 recognizes the PROJ_DATA environment variable, as a replacement
for PROJ_LIB (both are still recognized by PROJ >= 9.1. PROJ_LIB will be
retired in PROJ 10, whose release is unplanned for now)

@sbrunner
Copy link
Member

sbrunner commented Jun 17, 2024

Assuming the PROJ install in pkg-versions.yaml is required,

No, the version in this file is not required, this file is just used to trigger a rebuild when a package is updated.

@sbrunner
Copy link
Member

I just tried to reproduce the issue and I didn't succeed, can you share the files you used to reproduce it?

@geographika
Copy link
Contributor

@sbrunner - the following setup should trigger the error. The data isn't required - just setting the CONFIG "PROJ_DATA" "/usr/share/proj/" in the Mapfile. Not a major issue IMO but not sure what version of PROJ is added to the container in /usr/share/proj/ (and how).

docker pull camptocamp/mapserver:master
docker run --name mapserver_master -d -p 8080:80 -v /exercises/mapfiles:/etc/mapserver/mapfiles camptocamp/mapserver:master
docker exec -it mapserver_master /bin/bash
mapserv -nh "QUERY_STRING=map=/etc/mapserver/mapfiles/countries.map&mode=map"

# msProcessProjection(): Projection library error. proj error "Invalid PROJ string syntax" for "init=epsg:4326"

# docker stop mapserver_master
# docker rm mapserver_master

Mapfile:

MAP
    NAME "mymap"
    SIZE 800 400
    CONFIG "PROJ_DATA" "/usr/share/proj/"
    PROJECTION
        "init=epsg:4326"
    END
    EXTENT -180 -90 180 90
    LAYER
        NAME "countries"
        TYPE POLYGON
        STATUS DEFAULT
        CONNECTIONTYPE FLATGEOBUF
        DATA "data/naturalearth/ne_110m_admin_0_countries.fgb"
        CLASS
            STYLE
                COLOR 60 179 113
                OUTLINECOLOR 255 255 255
                WIDTH 1
            END
        END
    END
END

@yjacolin
Copy link
Member

I can reproduced also on my side. The fix looks good (remove CONFIG PROJ_LIB).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants