phpbar.de logo

Mailinglisten-Archive

[php] Entfernungen berechnen

[php] Entfernungen berechnen

Albin Blaschka albin.blaschka at sbg.ac.at
Son Aug 24 13:33:57 CEST 2003


Hallo Liste,

Ich möchte noch etwas zu dem Thread, wo es wieder einmal um Koordinaten und
Entfernungen berechnen ging, der vor kurzem hier lief (und so oder in ähnlicher
Form immer wieder aufgetaucht ist) loswerden:

Um es noch einmal zu verdeutlichen: Das Problem bei Entfernungsberechnungen auf
Basis Geographischen Koordinaten (also Grad, Minuten und Sekunden), ist die 
Form
der Erde - Jeder, der einen Apfel oder eine Orange versucht hat zu schälen, die
Schale im Ganzen heruntergebracht hat und diese Schale dann versucht flach auf
einen Tisch zu legen, hat das Problem direkt vor Augen ;-)

Die Ungenauigkeit steigt mit der Entfernung und ist von der konkreten
geographischen Breite abhängig.

Es gibt eine Library mit dem Namen .proj4 die alle möglichen Funktionen zur
Verfügung stellt, um mit Projektionen arbeiten zu können. Ist natürlich Open-
Source ;-) , die Web-Adresse lautet: http://www.remotesensing.org/proj
Unter http://www.remotesensing.org findet sich insgesamt einiges an 
Open-Source-
Software zu diesem Themenbereich.

Zwei relativ einfach zu handhabende Verfahren finden sich im 
Mailinglisten-Archiv
des bereits genannten Open-Source-Mapservers, die ich hier anhänge
(http://mapserver.gis.umn.edu/, Dokumenation unter
http://mapserver.gis.umn.edu/doc.html und das Mailinglisten-
Archiv findet sich unter
http://mapserver.gis.umn.edu/cgi-bin/wilma/mapserver-users)

Sollte jemand speziellere Fragen dazu haben, bin ich gerne bereit diese zu
beantworten, auch per PM, denn das könnte dann doch ganz schön OT werden ;-)

Albin

----------------------------------------------------------------------
<map-server-mailinglist>

Thread-Topic: [Mapserver-users] (Anti)geocoding and projections...

Ed McNierney, ed at topozone.com:

[...]
A lot depends on how accurate you need to be, but no, I don't think using 
degrees
as if they were square is a good idea.  Take your example (Warsaw, 
Poland).  It'
s at 52.25 degrees North latitude.  In Warsaw, one degree of latitude is 
111 km,
but one degree of longitude is only 68 km.  Computing simple distance as 
sqrt ((
delta latitude) ^ 2 + (delta longitude) ^ 2) will give you very incorrect 
numbers.

If you a comfortable doing the distance calculations like this in degrees, you
can get a much better result relatively easily by multiplying delta 
longitude by
the cosine of the average latitude.  This is still not accurate , but it's much
better and should work pretty well for short distances. It's not a geodetically
precise solution, but I'm suggesting it in case you need a simple calculation
that's not too bad.
[...]

Jan Hartmann, jhart at frw.uva.nl

[...]
Another method is projecting lat-lon values to the Azimuthal Equidistant
projection with central latitude and longitude at the point you are
measuring from. A characteristic of the AEQD is that all distances and
directions from the center point outward are accurate. With  Warsaw as
center point that would be (with command line PROJ):

proj +proj=aeqd +lon0=21d0 +lat_0=43d10

The coordinates returned for Warsaw are obviously 0 0, as this is the
center of projection.  The coordinates for e.g. Amsterdam with these
parameters are -1088.017 132.852. The distance is sqrt(1088^2 + 132^2) =
1096 km

There are several sites generating interactive maps in this projection
from a user chosen center, e.g for radio amateurs needing to know
distances and bearings measured from their own site
(http://www.wm7d.net/az_proj/az_html/azproj.shtml). In advertising, this
projection is used to make maps centered on tourist destinations, to
show visitors how accessible the site is and how many other attractions
are located nearby and in what direction.

Note that with PROJ this only works for locations on the hemisphere
around the chosen center point. Points farther away "wrap around", i.e.
show increasingly smaller distances, until the point at the exact
opposite of the globe has distance zero. I am not sure how MapServer
handles these cases: they don't look completely wrapped around, but they
also don't look like published maps as far as the outer hemisphere is
concerned.

A problem with the AEQD maps is that shape is distorted increasingly
from the center. A comparable projection is the Two Points Equidistant
projection, for which two control points have to be specified. Distances
are correct from both points to any other point on the map. Moreover,
distortion is minimal within the region of the two chosen points,
PROVIDED these are within 45 degrees of each other. Direction however
varies more than with the AEQD. The PROJ command (with Warsaw and
Amsterdam as control points) would be:

proj +proj=tpeqd +lon_1=21d0 +lat_1=52d15 +lon_2=4d54 +lat_2=52d21

A MapServer map with these parameters has minimal shape distortion for
North-West and Middle Europe and shows all distances to both cities
correctly. Directions are distorted somewhat, but for this region this
is scarcely noticeable.

This projection gives correct results in PROJ for distances larger than
a hemisphere: distance Warsaw-Melbourne: 15474 km. I'm not sure how
exact it is; it seems to have been used by Bell telephone for
calculating costs for long distance calls, so it's probably not far off
the mark.
[...]

</map-server-mailinglist>

--
***********************************************************************
** Albin Blaschka, Mag. rer. nat.
** Lektor für Geographische Informationverarbeitung am
** Institut für Botanik und Botanischer Garten,
** Universität Salzburg
** Hellbrunnerstr. 34, A-5020 Salzburg, Österreich
***********************************************************************




php::bar PHP Wiki   -   Listenarchive