Mapping/GIS Question

Hello,

This might be slighlty off topic, but perhaps someone has experience
with my question writing games or
other apps.

I’m trying to display the outlines of the major continents in either a
gtk canvas or by using an
SDL surface (currently just using GTK). I have the lat/long coordinates
representing a continent’s
political borders in a text file. I read in the file, collect the
points, and then try to display in a gtk drawing
area. Of course this doesn’t work properly, as the lat/long coordinates
do not translate well to
the x,y coordinates of the drawing area.

My question is, does anyone know of an elegant algorithm or way to
properly transpose these lat/long.
coordinates to x,y coordinates of a given drawing area?

Thanks in advance, and sorry if this is way off topic.

James

First: ad check fmaps.sourceforge.net

Second: It is what we call a projection and it is not simple, except if you
consider Lon<->x Lat<->y (funny maps). Look for the module geotrans on
www.freegis.org or www.remotesensing.org

Cheers.
Franck at sopac.org

James Caple wrote:> Hello,

This might be slighlty off topic, but perhaps someone has experience
with my question writing games or
other apps.

I’m trying to display the outlines of the major continents in either a
gtk canvas or by using an
SDL surface (currently just using GTK). I have the lat/long coordinates
representing a continent’s
political borders in a text file. I read in the file, collect the
points, and then try to display in a gtk drawing
area. Of course this doesn’t work properly, as the lat/long coordinates
do not translate well to
the x,y coordinates of the drawing area.

My question is, does anyone know of an elegant algorithm or way to
properly transpose these lat/long.
coordinates to x,y coordinates of a given drawing area?

Thanks in advance, and sorry if this is way off topic.

James


gtk-app-devel-list mailing list
gtk-app-devel-list at gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

James Caple wrote:

I’m trying to display the outlines of the major continents in either a
gtk canvas or by using an
SDL surface (currently just using GTK). I have the lat/long coordinates
representing a continent’s
political borders in a text file. I read in the file, collect the
points, and then try to display in a gtk drawing
area. Of course this doesn’t work properly, as the lat/long coordinates
do not translate well to
the x,y coordinates of the drawing area.

My question is, does anyone know of an elegant algorithm or way to
properly transpose these lat/long.
coordinates to x,y coordinates of a given drawing area?

The problem of representing spherical (lat./long.) coordinates in a
cartesian plane are well-known to map-makers - any good geometry
textbook should cover the relevant issues. I’d also recommend OpenGL as
a good bridge between 3D and 2D. You can use a gtkglarea widget to
incorporate your graphics into the rest of your GTK+ UI or, if you
prefer C++, the SDPGTK library at www.k-3d.com

Regards,
Timothy M. Shead

I’ll drift a bit off-topic myself here…

You’ve stumbled into a very tricky problem in mathematics and
cartography that there isn’t one right answer to. If you are going to
project an image from the surface of a sphere (like the earth) to a
place (like a piece of paper, or a monitor), you necessarily have to
introduce distortions. There are a bunch of different schemes for
doing this, each with different properties.

One of the most standard is the Mercator projection, which has some
properties that make it suitable for nautical navigation. It is a
"conformal mapping", which means that angles are preserved under the
transformation. However, it distorts area rather badly as you move
away from the equator. (These are the maps that make Greenland and
Antarctica look really huge.)

There are also a family of projections that preserve the relative
areas of mapped objects, Given the forum, I’d be remiss not to mention
the Gnomonic projection, which distorts areas and angles but has the
nice property of mapping spherical great circles into straight lines.
There are a whole bunch of different methods, some of which have nice
mathematical/cartographic properties but produce pictures that are
really strange-looking.

Luckily, there is a good source of information about this stuff on the
Internet. http://mathworld.wolfram.com/topics/MapProjections.html
gives formulas for (long,lat) -> (x,y) conversions for many different
projections and shows examples of the globe under the various
transformations. You can look through the many different options
and pick the one you like the best.

-JTOn Sat, Aug 05, 2000 at 07:36:14PM -0400, James Caple wrote:

My question is, does anyone know of an elegant algorithm or way to
properly transpose these lat/long.
coordinates to x,y coordinates of a given drawing area?


GNU/Linux: Free your mind and your OS will follow.

Hi!

I’m trying to develop something similar… please, e-mail me private so we
can talk a little :slight_smile:

Eduardo.On Sat, 5 Aug 2000, James Caple wrote:

Hello,

This might be slighlty off topic, but perhaps someone has experience
with my question writing games or
other apps.

I’m trying to display the outlines of the major continents in either a
gtk canvas or by using an
SDL surface (currently just using GTK). I have the lat/long coordinates
representing a continent’s
political borders in a text file. I read in the file, collect the
points, and then try to display in a gtk drawing
area. Of course this doesn’t work properly, as the lat/long coordinates
do not translate well to
the x,y coordinates of the drawing area.

My question is, does anyone know of an elegant algorithm or way to
properly transpose these lat/long.
coordinates to x,y coordinates of a given drawing area?

Thanks in advance, and sorry if this is way off topic.

James

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1> On Sat, Aug 05, 2000 at 07:36:14PM -0400, James Caple wrote:

My question is, does anyone know of an elegant algorithm or way to
properly transpose these lat/long.
coordinates to x,y coordinates of a given drawing area?

I’ll drift a bit off-topic myself here…

You’ve stumbled into a very tricky problem in mathematics and
cartography that there isn’t one right answer to. If you are going to
project an image from the surface of a sphere (like the earth) to a
place (like a piece of paper, or a monitor), you necessarily have to
introduce distortions. There are a bunch of different schemes for
doing this, each with different properties.

One of the most standard is the Mercator projection, which has some
properties that make it suitable for nautical navigation. It is a
"conformal mapping", which means that angles are preserved under the
transformation. However, it distorts area rather badly as you move
away from the equator. (These are the maps that make Greenland and
Antarctica look really huge.)

There are also a family of projections that preserve the relative
areas of mapped objects, Given the forum, I’d be remiss not to mention
the Gnomonic projection, which distorts areas and angles but has the
nice property of mapping spherical great circles into straight lines.
There are a whole bunch of different methods, some of which have nice
mathematical/cartographic properties but produce pictures that are
really strange-looking.

Luckily, there is a good source of information about this stuff on the
Internet. http://mathworld.wolfram.com/topics/MapProjections.html
gives formulas for (long,lat) -> (x,y) conversions for many different
projections and shows examples of the globe under the various
transformations. You can look through the many different options
and pick the one you like the best.

I have code doing these kinds of projections, based on Pascal code from
a very old article from Byte Magazine I saw more than ten years ago…
Fortunately, I still have my C conversion of it, but it uses Motif and
Xlib for the display; never got around to updating it to use GTK+ or
something like that. It currently supports Mercator, Equidistant
Cylindrical, Miller, Sinusoidal, Hammer, Orthographic, and Stereographic
projections. I can email this code (which includes a digitized map of the
world with 7574 world coastline points) to anyone who’s interested.

The article was by Robert Miller and Francis Reddy: “Mapping the World in
Pascal”, BYTE Magazine, December 1987, page 329.


Rafael R. Sevilla <@Rafael_R_Sevilla> +63 (2) 4342217
ICSM-F Development Team, UP Diliman +63 (917) 4458925
PGP Key available at http://home.pacific.net.ph/~dido/dido.pgp

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.1i

iQA/AwUBOY0hoGqsapcaCwm7EQLNoQCfcW6fib/v5MDqoh+Snya2DdouITMAn2c7
zCCNd2jionRTblMWPIWX7FKs
=skwb
-----END PGP SIGNATURE-----

My question is, does anyone know of an elegant algorithm or way to
properly transpose these lat/long. coordinates to x,y coordinates
of a given drawing area?

The type of transformation you’re asking about is called a map
projection. It’s not a simple problem, but it is one that has been
extensively studied. The standard reference in this area is probably
John Snyder’s Map Projections – A Working Manual, available from
the US Gov’t Printing Office as well as most university libraries.
This book comes with a beautiful set of example maps that compare and
contrast the tradeoffs made by the various map projections.

From there it’s standard engineering – pick a set of tradeoffs that
you can live with, and plug the numbers into the appropriate formula.

– John Kodis.On Sat, Aug 05, 2000 at 07:36:14PM -0400, James Caple wrote: