Boost logo

Geometry :

Subject: [ggl] point conversion geographic <-> cartesian
From: Barend Gehrels (barend.gehrels)
Date: 2010-11-05 08:07:23

hi Kris,

Welcome to the list.

> I would like to keep a list of points in geographic coordinates, all
> of which should lie in the same region (lets say max distance would be
> 500 km). I would like to display their positions on the screen, so I
> need some way to convert them to cartesian.

So you want to transform those geographic coordinates.

> So far I found the distance algorithm, which allows me to perform a
> conversion to cartesian as follows:
> Given points P1(lon1,lat1), P2(lon2,lat2), asuming P1cart=(0,0),
> P2cart=(x2?,y2?) can be calculated using the distance algorithm:
> x2=distance([lon1,lat1],[lon2,lat1]);
> y2=distance([lon1,lat1],[lon1,lat2]).
> I suspect this is not an efficient conversion, bot that does not
> consern me right now.

I've never seen distance used for this, and I don't think that it is
possible. If possible, you will get an equidistant projection for sure ;-)

However, you'd better use an existing projection. Boost.Geometry
supports (in the extensions folder) nearly 100 of them, converted from
proj4. Depending on your area you can select one. There is many
documentation on projections on the Internet.

> I also need a conversion the other way - that is:
> Given P1(lon1,lat1), P1cart=(0,0) and P2cart(x2,y2), P2=(lon2?,lat2?)
> I have not found, how this can be done with bgl

Using projections, you can transform points from geo to cartesian,
(forward), and back (inverse).

Besides projections, you can also transform the geo-points using
translation/scaling (this is actually the most simple projection, plate

Regards, Barend

Geometry list run by mateusz at