Feature request #3586

use authid instead of proj.4 strings

Added by Jürgen Fischer about 13 years ago. Updated about 13 years ago.

Status:Closed
Priority:Low
Assignee:Jürgen Fischer
Category:Projection Support
Pull Request or Patch supplied: Resolution:fixed
Easy fix?:No Copied to github as #:13646

Description

Currently we try to use the proj.4 strings to store references to coordinate
systems (eg. for the default project crs). Unfortunately the proj.4
string isn't unique in our database:

sqlite> select count(*),parameters from tbl_srs group by parameters order by count(*) desc limit 10;
54|+proj=longlat +ellps=intl +no_defs
27|+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
21|+proj=longlat +ellps=clrk80 +no_defs
17|+proj=longlat +ellps=bessel +no_defs
15|+proj=longlat +ellps=clrk66 +no_defs
13|+proj=longlat +a=6378249.2 +b=6356515 +no_defs
11|+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs
9|+proj=longlat +ellps=GRS80 +no_defs
9|+proj=longlat +ellps=krass +no_defs
9|+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m +no_defs
sqlite> select auth_name,auth_id,description,parameters from tbl_srs where parameters='+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs' limit 1;
EPSG|4148|Hartebeesthoek94|+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs

So selecting 'EPSG:4326' as default CRS results in 'EPSG:4148 - Hartebeesthoek94' - which obviously is irritating.

The attached patch switches to the use of authid instead of proj.4 strings. Any objections to commit it for 1.7?

crs.diff Magnifier - use authid instead of proj.4 strings to identify CRS (13.3 KB) Jürgen Fischer, 2011-03-09 12:58 PM

crs-borys.diff Magnifier - small modifications (14 KB) Borys Jurgiel, 2011-03-10 01:50 AM

History

#1 Updated by Marco Hugentobler about 13 years ago

Looks good to me. +1 for commit.

Marco

#2 Updated by Borys Jurgiel about 13 years ago

I've slightly modified your patch:

1. Also save the authid to QSettings, not only read ;-) (qgsoptions.cpp 642 and 646)

2. Use layerDefaultCrs Qsettings key instead of misleading defaultCrs. As the patch breaks this setting anyway, I take a opportunity to clean up a bit. (qgsoptions.cpp 191 and 642; qgisapp.cpp 361)

By the way. Seems it works not only with epsg ids. Is the note in api doc out of date?
http://doc.qgis.org/head/classQgsCoordinateReferenceSystem.html#5789a11684af1415ffc74d7ce9ab91f0

#3 Updated by Jürgen Fischer about 13 years ago

Replying to [comment:2 borysiasty]:

1. Also save the authid to QSettings, not only read ;-) (qgsoptions.cpp 642 and 646)

if you insist ;)

By the way. Seems it works not only with epsg ids. Is the note in api doc out of date?
http://doc.qgis.org/head/classQgsCoordinateReferenceSystem.html#5789a11684af1415ffc74d7ce9ab91f0

Oh, yes. That note was probably already there, when we added the auth_name column to tbl_srs...

#4 Updated by Jürgen Fischer about 13 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

applied in 4c7b539c (SVN r15420).

#5 Updated by Borys Jurgiel about 13 years ago

  • Status changed from Closed to Feedback
  • Resolution deleted (fixed)

But what with project files? Both authid and proj string are saved.

JEF, could you please confirm that authid is higher prriority and hopefully close the ticket again?

#6 Updated by Jürgen Fischer about 13 years ago

  • Status changed from Feedback to Closed
  • Resolution set to fixed

Replying to [comment:5 borysiasty]:

But what with project files? Both authid and proj string are saved.

JEF, could you please confirm that authid is higher prriority and hopefully close the ticket again?

looks like it. order is authid, epsg, proj.4 and as last resort a CRS initialized with all the values from the node. Otherwise we should have hit the 'Hartebeesthoek94' problem earlier...

Also available in: Atom PDF