[GRASS-dev] [GRASS GIS] #167: g.region: reports wrong center longitude and LL bounding box

#167: g.region: reports wrong center longitude and LL bounding box
--------------------------+-------------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: default | Version: svn-develbranch6
Keywords: g.region 180 |
--------------------------+-------------------------------------------------
Hi,

if you set up a region which crosses 180 longitude, g.region -b and -l
have problems calculating the center coord:

create a new location using EPSG 3112. (Australia; Lambert CC)
{{{
g.region n=1973000 s=-6188000 w=-5175000 e=4846000 res=1000
d.mon x0; d.grid -g 10
# looks ok, if you ignore that grid lines E of 180 are missing
}}}
---
{{{
g.region -b # print max LL bounding box (WGS84)
north longitude: 19:37:06.913074N
south longitude: 44:19:08.88403S
west latitude: 69:34:08.058065E
east latitude: 168:13:13.623433E
center latitude: 118:53:40.840749E
center longitude: 12:21:00.985478S
}}}

/general/g.region/printwindow.c:
  * lat/lon swapped; "north longitude" -> "North latitude" etc.

after fixing that, the max bounding box calc still is wrong.
furthest east is the bottom right corner (165W) but -b reports the value
at the top right (168E). [simple a>b test too simple?]
That eastern boundary value is used for the center lon calc, so the center
lon is wrong as well (skewed to the west).

---
{{{
g.region -l # print lat/lon (current ellipsoid)
north-west corner: long: 97:34:49.670961E lat: 20:13:08.52602N
north-east corner: long: 168:13:13.623433E lat: 19:37:06.913074N
south-east corner: long: 165:02:10.589072W lat: 44:19:08.88403S
south-west corner: long: 69:34:08.058065E lat: 42:56:48.735964S
center longitude: 42:35:00.190847E
center latitude: 11:51:25.545225S
rows: 8161
cols: 10021
}}}

this time it gets the box corners correct but the center longitude is
wrong. it's looking around the wrong side of the world and the answer is
apparently 180deg out.

also note the center lat is different to the -b version, and that with -l
the NW corner's lat is bigger than the NE lat, but for -b max bounding box
the more southerly 19:37N is used, not the further out 20:13N.

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/167&gt;
GRASS GIS <http://grass.osgeo.org>

#167: g.region: reports wrong center longitude and LL bounding box
----------------------+-----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-develbranch6
Resolution: | Keywords: g.region 180
----------------------+-----------------------------------------------------
Comment (by hamish):

Center coord via another method for comparison:

{{{
g.region -c
center easting: -164500.000000
center northing: -2107500.000000

echo "-164500 -2107500" | m.proj -o --quiet
132d26'33.612"E 18d18'35.426"S 0.000
}}}

which doesn't match either -b or -l's version, but looks about right if
you plot it over 'd.grid -g 10':
{{{
# d.mark from wiki addons
d.mark -m at="-164500,-2107500"
}}}

compare:
{{{
g.region -l
center longitude: 42:35:00.190847E + 180 = +137.4166137
center latitude: 11:51:25.545225S

echo "137.4166137 11d51'25.545225\"S" | m.proj -i --quiet
380455.32 -1390800.80 0.00
d.mark -m at="380455.32,-1390800.80" fcolor=red
## (off a way to the NE)
}}}

{{{
g.region -b
center [lon]: 118:53:40.840749E
center [lat]: 12:21:00.985478S

echo "118d53'40.840749\"E 12d21'00.985478\"S" | m.proj -i --quiet
-1671525.94 -1541908.71 0.00
d.mark -m at="-1671525.94,-1541908.71" fcolor=blue
## (off even further away to the NW)
}}}

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/167#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>