grass
grass copied to clipboard
libproj: simple check for area of use
This PR adds a simple check if reprojection would fall outside the intended area of use of the target CRS.
I would prefer to refuse reprojection in these extreme cases, but this might be too restrictive. If subsequent errors occur because reprojected coordinates are invalid, this can be changed accordingly to actually refuse reprojection which is the current behaviour, but without explanation why.
I have resolved the indentation-related conflicts here.
A test: I reprojected an Indonesian vector map into the NC sample dataset and do not yet see the warning being triggered:
GRASS nc_spm_08_grass7/user1:grass_main > v.proj location=utm49S_32749 mapset=hutan_mulya input=hutan_mulya_box
Found 2 possible transformations
************************
Operation 1:
Description: Inverse of UTM zone 49S + Inverse of NAD83(HARN) to WGS 84 (3)
+ SPCS83 North Carolina zone (meters)
Area of use: United States (USA) - CONUS onshore - Alabama; Arizona;
Arkansas; California; Colorado; Connecticut; Delaware; Florida; Georgia;
Idaho; Illinois; Indiana; Iowa; Kansas; Kentucky; Louisiana; Maine;
Maryland; Massachusetts; Michigan; Minnesota; Mississippi; Missouri;
Montana; Nebraska; Nevada; New Hampshire; New Jersey; New Mexico; New York;
North Carolina; North Dakota; Ohio; Oklahoma; Oregon; Pennsylvania; Rhode
Island; South Carolina; South Dakota; Tennessee; Texas; Utah; Vermont;
Virginia; Washington; West Virginia; Wisconsin; Wyoming.
Accuracy within area of use: 1 m
PROJ string:
+proj=pipeline +step +inv +proj=utm +zone=49 +south +ellps=WGS84 +step
+proj=push +v_3 +step +proj=cart +ellps=WGS84 +step +inv +proj=helmert
+x=-0.991 +y=1.9072 +z=0.5129 +rx=-0.0257899075194932
+ry=-0.0096500989602704 +rz=-0.0116599432323421 +s=0
+convention=coordinate_frame +step +inv +proj=cart +ellps=GRS80 +step
+proj=pop +v_3 +step +proj=lcc +lat_0=33.75 +lon_0=-79
+lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0
+ellps=GRS80
************************
Operation 2:
Description: Inverse of UTM zone 49S + Inverse of NAD83(HARN) to WGS 84 (1)
+ SPCS83 North Carolina zone (meters)
Area of use: American Samoa - onshore - Tutuila, Aunu'u, Ofu, Olesega, Ta'u
and Rose islands. Guam - onshore. Northern Mariana Islands - onshore.
Puerto Rico - onshore. United States (USA) - onshore Alabama, Alaska,
Arizona, Arkansas, California, Colorado, Connecticut, Delaware, Florida,
Georgia, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky,
Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota,
Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New
Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma,
Oregon, Pennsylvania, Rhode Island, South Carolina, South Dakota,
Tennessee, Texas, Utah, Vermont, Virginia, Washington, West Virginia,
Wisconsin and Wyoming; offshore Gulf of Mexico continental shelf (GoM OCS).
US Virgin Islands - onshore.
Accuracy within area of use: 2 m
PROJ string:
+proj=pipeline +step +inv +proj=utm +zone=49 +south +ellps=WGS84 +step
+proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667
+lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80
************************
See also output of:
projinfo -o PROJ -s "EPSG:32749" -t "EPSG:3358"
Please provide the appropriate PROJ string with the pipeline option
************************
Selected PROJ pipeline:
+proj=pipeline +step +inv +proj=utm +zone=49 +south +ellps=WGS84 +step
+proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667
+lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +ellps=GRS80
************************
Reprojecting primitives ...
Building topology for vector map <hutan_mulya_box@user1>...
Registering primitives...
Building areas...
100%
Attaching islands...
100%
Attaching centroids...
100%
@metzm shall I bump this PR to 8.4.0?