Opened 13 years ago

Closed 13 years ago

#3586 closed patch (fixed)

use authid instead of proj.4 strings

Reported by: jef Owned by: jef
Priority: major: does not work as expected Milestone: Version 1.7.0
Component: Projection Support Version:
Keywords: Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

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?

Attachments (2)

crs.diff (13.3 KB ) - added by jef 13 years ago.
use authid instead of proj.4 strings to identify CRS
crs-borys.diff (14.0 KB ) - added by borysiasty 13 years ago.
small modifications

Download all attachments as: .zip

Change History (8)

by jef, 13 years ago

Attachment: crs.diff added

use authid instead of proj.4 strings to identify CRS

comment:1 by mhugent, 13 years ago

Looks good to me. +1 for commit.

Marco

comment:2 by borysiasty, 13 years ago

I've slightly modified your patch:

  1. Also save the authid to QSettings, not only read ;-) (qgsoptions.cpp 642 and 646)
  1. 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

by borysiasty, 13 years ago

Attachment: crs-borys.diff added

small modifications

in reply to:  2 comment:3 by jef, 13 years ago

Replying to 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...

comment:4 by jef, 13 years ago

Resolution: fixed
Status: newclosed

applied in r15419.

comment:5 by borysiasty, 13 years ago

Resolution: fixed
Status: closedreopened

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?

in reply to:  5 comment:6 by jef, 13 years ago

Resolution: fixed
Status: reopenedclosed

Replying to 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...

Note: See TracTickets for help on using tickets.