Opened 4 years ago

Closed 3 years ago

#5370 closed enhancement (fixed)

Linear Units support in proj4 parser

Reported by: Kyle Shannon Owned by: Kyle Shannon
Priority: normal Milestone: 1.11.0
Component: OGR_SRS Version: svn-trunk
Severity: normal Keywords: proj4
Cc:

Description

We should add (as per comment in ogr_srs_proj4.cpp) all supported units to proj4 parsing as reported by cs2cs -lu.

Change History (10)

comment:1 Changed 4 years ago by Kyle Shannon

added in trunk r26902 and tests in r26903. See QGIS ticket as well:

http://hub.qgis.org/issues/9414

comment:2 Changed 4 years ago by 45136

I created some basic tests for ogr2ogr:

ogr2ogr -s_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" -t_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=km +no_defs" mm1.shp mm.csv
ogr2ogr -s_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=mm +no_defs" -t_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" mm2.shp mm.csv
ogr2ogr -s_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=mm +no_defs" -t_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=mm +no_defs" mm3.shp mm.csv
ogr2ogr -s_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +to_meter=0.001 +no_defs" -t_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +to_meter=0.001 +no_defs" mm4.shp mm.csv

Input file mm.csv:

id;WKT
1;Point(0 0)
2;Point(1000 0)
3;Point(1000 1000)

With gisinternals dev build from today, all shapefiles and projections are created as expected: Extent of the first two is between 0 and 1, the mm3 and mm4 between 0 and 1000. units of .prj are: mm1 "kilometre",1000 mm2 "Meter",1 mm3 "mm",0.001 mm4 "unknown",0.001 So ogr2ogr works correct now (and did not up to yesterdays build). It would be nice if the unit names could be equally British or Amercan or abbreviated.

In QGIS, only mm3 has an extent of 1 meter, the others 1 kilometer. This is wrong for mm2 and mm4, which should be 1 square meter.

comment:3 Changed 4 years ago by etourigny

Kyle - shouldn't this be a bug fix rather than a feature? Therefore, shouldn't it be added to 1.10 as well?

cheers Etienne

comment:4 in reply to:  2 ; Changed 4 years ago by Kyle Shannon

Status: newassigned

Replying to 45136:

I created some basic tests for ogr2ogr:

ogr2ogr -s_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" -t_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=km +no_defs" mm1.shp mm.csv
ogr2ogr -s_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=mm +no_defs" -t_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" mm2.shp mm.csv
ogr2ogr -s_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=mm +no_defs" -t_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=mm +no_defs" mm3.shp mm.csv
ogr2ogr -s_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +to_meter=0.001 +no_defs" -t_srs "+proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +to_meter=0.001 +no_defs" mm4.shp mm.csv

Input file mm.csv:

id;WKT
1;Point(0 0)
2;Point(1000 0)
3;Point(1000 1000)

With gisinternals dev build from today, all shapefiles and projections are created as expected: Extent of the first two is between 0 and 1, the mm3 and mm4 between 0 and 1000. units of .prj are: mm1 "kilometre",1000 mm2 "Meter",1 mm3 "mm",0.001 mm4 "unknown",0.001 So ogr2ogr works correct now (and did not up to yesterdays build). It would be nice if the unit names could be equally British or Amercan or abbreviated.

I will check on the unit names.

In QGIS, only mm3 has an extent of 1 meter, the others 1 kilometer. This is wrong for mm2 and mm4, which should be 1 square meter.

I may be missing something, but it appears mm2 should have an extent of 1km. As for to_meter, I did not add any support for that tag and probably should be a separate issue.

comment:5 in reply to:  3 Changed 4 years ago by Kyle Shannon

Replying to etourigny:

Kyle - shouldn't this be a bug fix rather than a feature? Therefore, shouldn't it be added to 1.10 as well?

cheers Etienne

I could see it as either adding support for units(feature) or a bug fix. I guess I can backport.

comment:6 in reply to:  4 Changed 4 years ago by 45136

Replying to kyle:

I may be missing something, but it appears mm2 should have an extent of 1km.

No, in the second step I converted 1000mm to 1m in ogr2ogr to test if the reprojection uses the correct units on both sides.

comment:7 Changed 4 years ago by Kyle Shannon

45136, I can update the 'human readable' representations, does the output of cs2cs -lu work?

comment:8 in reply to:  7 Changed 4 years ago by 45136

Replying to kyle:

45136, I can update the 'human readable' representations, does the output of cs2cs -lu work?

If you think of the last column, yes.

I would also favour backporting the bug to GDAL 1.10, if possible.

comment:9 Changed 4 years ago by Kyle Shannon

I have a patch ready to fix the naming, although I am hesitant to dump a bunch of random strings into wkt, fearing it would break random parsers. Does anyone have any references to standard wkt names for linear units? I could not find any.

comment:10 Changed 3 years ago by Kyle Shannon

Resolution: fixed
Status: assignedclosed

Committed fix for names in r27108, and r27109. I missed a file, that's why there is two commits. 1.11 is near, didn't backport.

Note: See TracTickets for help on using tickets.