[GRASS-dev] latlong problem

Glynn Clements glynn at gclements.plus.com
Wed Mar 7 12:32:43 EST 2007


Martin Landa wrote:
> Hi Glynn,
> 
> 2007/3/7, Glynn Clements <glynn at gclements.plus.com>:
> 
> > > there is a significant problem in LatLong location. Try the following:
> > >
> > > g.region n=80 s=-80 w=-170 e=170 res=1;
> > > v.in.region out=reg;
> > > g.region n=90 s=-90 w=-180 e=180 res=1;
> > > d.erase;d.vect reg
> > > [1] should be [2]
> >
> > No, [1] is correct.
> >
> > Given two points at the same latitude, each 10 degrees either side of
> > the 180th meridian, the line segment between them is deemed to be the
> > one which subtends 20 degrees and crosses the 180th meridian, not the
> > one which subtends 340 degrees and crosses the prime meridian.
> >
> > IOW, "shorter" has a higher priority than "doesn't cross the 180th
> > meridian".
> 
> OK, then I understand. Anyway, the centroid should be placed inside
> the area. It is at least confusing.

Ah; I missed that part. Yes, the centroid should definitely lie inside
the area (i.e. on the 180th meridian in this case).

> So the problem with "buggy" maps which Markus described still remains.

Personally, I'd be tempted to just treat the 180th meridian as a
discontinuity (New Zealanders and Japanese would have to stick to
using projected locations). I wouldn't be surprised if there are a
*lot* of places in the code which ought to contain specific code to
handle longitude wrapping but don't.

[E.g. "d.vect ... render=c" doesn't handle it correctly. 
D_polygon_clip() does the clipping in geographic coordinates, before
transforming the vertices to display coordinates. Most of the time,
this is preferable, as you eliminate the conversion overhead for any
points which are discarded by clipping.]

Actually, this isn't a problem which can be "solved". What do you do
if you *want* a polygon which spans 340° of longitude? How do you
interpret a polygon which spans exactly 180°; which hemisphere does it
cover?

IOW, I don't think that we'll ever get this "right".

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list