[PROJ] How to match a proj string to the db?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PROJ] How to match a proj string to the db?

Nyall Dawson
Hi list

Still fighting with transitioning QGIS to proj 6. (Honestly, I wonder
if this task will ever end...!)

If I have a proj string (say +proj=longlat +datum=WGS84 +no_defs
+type=crs), how can I match this back to an authority/code from proj's
db?

proj_identify doesn't seem to be capable of this (maybe by design? The
dox say: "This is implemented for GeodeticCRS, ProjectedCRS,
VerticalCRS and CompoundCRS"). The dox for proj_identify also have a
cryptic note "The candidate CRSs are either hard-coded, or looked in
the database when authorityFactory is not null." What exactly does
this mean? I can't see where authorityFactory is specified, or a hard
coded list of candidates is specified either... Is this outdated
documentation?

Nyall
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: How to match a proj string to the db?

Even Rouault-2
Hi Nyall,

> If I have a proj string (say +proj=longlat +datum=WGS84 +no_defs
> +type=crs), how can I match this back to an authority/code from proj's
> db?

You just hit a bug. The issue is that instanciating from PROJ string for a
GeographicCRS like the above creates a long,lat coordinate system, whereas
EPSG:4326 is lat,long. I've just fixed this in master and 6.1 branches by
setting a flag to indicate that CRS identification must be axis order
tolerant.

>
> proj_identify doesn't seem to be capable of this (maybe by design? The
> dox say: "This is implemented for GeodeticCRS, ProjectedCRS,
> VerticalCRS and CompoundCRS"). The dox for proj_identify also have a
> cryptic note "The candidate CRSs are either hard-coded, or looked in
> the database when authorityFactory is not null." What exactly does
> this mean? I can't see where authorityFactory is specified, or a hard
> coded list of candidates is specified either... Is this outdated
> documentation?

The later part is a copy&paste from the corresponding C++ which in clearer
terms translate to "when the database is available". Also fixed.

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: How to match a proj string to the db?

Nyall Dawson
On Sun, 12 May 2019 at 17:09, Even Rouault <[hidden email]> wrote:

>
> Hi Nyall,
>
> > If I have a proj string (say +proj=longlat +datum=WGS84 +no_defs
> > +type=crs), how can I match this back to an authority/code from proj's
> > db?
>
> You just hit a bug. The issue is that instanciating from PROJ string for a
> GeographicCRS like the above creates a long,lat coordinate system, whereas
> EPSG:4326 is lat,long. I've just fixed this in master and 6.1 branches by
> setting a flag to indicate that CRS identification must be axis order
> tolerant.
>

Great -- thanks for the confirmation and quick response!

> >
> > proj_identify doesn't seem to be capable of this (maybe by design? The
> > dox say: "This is implemented for GeodeticCRS, ProjectedCRS,
> > VerticalCRS and CompoundCRS"). The dox for proj_identify also have a
> > cryptic note "The candidate CRSs are either hard-coded, or looked in
> > the database when authorityFactory is not null." What exactly does
> > this mean? I can't see where authorityFactory is specified, or a hard
> > coded list of candidates is specified either... Is this outdated
> > documentation?
>
> The later part is a copy&paste from the corresponding C++ which in clearer
> terms translate to "when the database is available". Also fixed.

What about the "hard-coded" part of the text? What exactly does this
mean? I can't see anyway to specify this list of hard-coded
candidates.

Nyall



>
> Even
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: How to match a proj string to the db?

Nyall Dawson
On Sun, 12 May 2019 at 17:21, Nyall Dawson <[hidden email]> wrote:

>
> On Sun, 12 May 2019 at 17:09, Even Rouault <[hidden email]> wrote:
> >
> > Hi Nyall,
> >
> > > If I have a proj string (say +proj=longlat +datum=WGS84 +no_defs
> > > +type=crs), how can I match this back to an authority/code from proj's
> > > db?
> >
> > You just hit a bug. The issue is that instanciating from PROJ string for a
> > GeographicCRS like the above creates a long,lat coordinate system, whereas
> > EPSG:4326 is lat,long. I've just fixed this in master and 6.1 branches by
> > setting a flag to indicate that CRS identification must be axis order
> > tolerant.
> >
>
> Great -- thanks for the confirmation and quick response!

I've just tested with master, and I'm still struggling here.

PJ* crs = proj_create( 0, "+proj=longlat +datum=WGS84 +no_defs +type=crs")
if ( PJ_OBJ_LIST *crsList = proj_identify( 0, crs, nullptr, nullptr,
&confidence ) )
{
 // never reached, regardless of proj string
}

Should proj_identify work ok in this situation?

Nyall





> > http://www.spatialys.com
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: How to match a proj string to the db?

Even Rouault-2
On dimanche 12 mai 2019 20:25:52 CEST Nyall Dawson wrote:
> PJ* crs = proj_create( 0, "+proj=longlat +datum=WGS84 +no_defs +type=crs")
> if ( PJ_OBJ_LIST *crsList = proj_identify( 0, crs, nullptr, nullptr,
> &confidence ) )
> {
>  // never reached, regardless of proj string
> }

Hum, works for me. Is PROJ_LIB properly set ?


> What about the "hard-coded" part of the text? What exactly does this
> mean? I can't see anyway to specify this list of hard-coded
> candidates.

No, it means that there are a few CRS whose definitions is hard coded and so
identify() might be able to identiy them even if the database is not
available. But you can ignore that implementation detail.

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: How to match a proj string to the db?

Nyall Dawson
On Mon, 13 May 2019 at 11:54, Even Rouault <[hidden email]> wrote:

>
> On dimanche 12 mai 2019 20:25:52 CEST Nyall Dawson wrote:
> > PJ* crs = proj_create( 0, "+proj=longlat +datum=WGS84 +no_defs +type=crs")
> > if ( PJ_OBJ_LIST *crsList = proj_identify( 0, crs, nullptr, nullptr,
> > &confidence ) )
> > {
> >  // never reached, regardless of proj string
> > }
>
> Hum, works for me. Is PROJ_LIB properly set ?

Sorry for the noise, false alarm. It *is* working correctly now!

Nyall
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj