class GeoObject


class GeoObject

A GeoObject represents georeferenced data. Latitude, longitude and name of the location are the basic information.

GeoObject = new GeoObject(string $name, mixed $latitude, mixed $longitude [, boolean $degree])

The name describes the location of the GeoObject, so this could be the name of a city. You may pass the latitude and longitude as float or as a string.

If a string is passed it must contain dms data like N 51° 24' 24''. Degree, minute and second must be seperated by space and could contain °, ' and ". The direction must be passes as N, S, W, E, O (german East) or +/-.

When float values are used one can pass radiant or degree values. By default it is assumed that you pass radiant values.

Set degree to true if you use degree values. Actually there is an autodetection: if either longitude or latitude is greater than PI (3.1414...) it is recognized that the values must be in degrees. So the degree parameter is only interesting when you create GeoObjects close by the Gulf of Guinea where zero meridian and equator meet (see example).

For some methods it might be useful to create a dummy GeoObject. Just call the constructor without any paramters. Name is set to "" and lat/long to 0.

Properties

string $name : Name of the location
float $latitude : Latitude in degree, e.g. 51.4066666
float $longitude : Longitude in degree, e.g. 7.4419444
float $latitudeRad : Latitude in radians, e. g. 0.897216
float $longitudeRad : Longitude in radians, e. g. 0.129886
string $latitudeDMS : Latitude DMS style, e. g. N 51° 24' 24''
float $longitudeDMS : Longitude DMS style, e. g. E 7° 26' 31''

Methods

float getEarthRadius([string $unit])
float getDistance(GeoObject &$geoObject [, string $unit])
string getDistanceString(GeoObject &$geoObject [, string $unit])
float getDistanceNS(GeoObject &$geoObject [, string $unit])
float getDistanceWE(GeoObject &$geoObject [, string $unit])
string getOrientation(GeoObject &$geoObject [, int $form [, string $language]])
string getRDFPointEntry([int $indent])
string getRDFDataFile()
string getInfo()
string dms2deg($dms)
string deg2dms($degFloat [, $decPlaces])

Example

This example shows how to create one location in different ways.

$myHome = new GeoObject("My Home", "N 51 24 24", "O 7 26 31");
print $myHome->latitudeDMS." = ".$myHome->latitude." = ".$myHome->latitudeRad;

N 51° 24' 24'' = 51.406666 = 0.8972156

// Here myHome ist created with degree and radians
$myHome = new GeoObject("My Home", 51.40666, 7.441944);
$myHome = new GeoObject("My Home", 0.897216, 0.192886);

The parameter wether the values are in degree becomes redundant, because the degree values are greater than PI. Here is how one would create a location in the Gulf of Guinea:

$gulfOfGuinea = new GeoObject("Gulf of Guinea", 2., 2.5, true);
$gulfOfGuinea = new GeoObject("Gulf of Guinea", 0.034907, 0.043633);
$gulfOfGuinea = new GeoObject("Gulf of Guinea", "2 0 0", "2 30 00");