|$pt =& new gPoint(["DATUM"]);
Creates a new gPoint object. The DATUM parameter
may be one of the following:
"Bessel 1841 Nambia"
"Fischer 1960 Mercury"
"Modified Fischer 1960"
"South American 1969"
If left empty, then the default DATUM is "WGS 84". The
datum reference ellipsoids were derived from Peter
Dana's web page (now moved to) at http://www.colorado.edu/geography/gcraft/notes/datum/datum_f.html.
According to the original source this data is from Defense Mapping
Agency. 1987b. DMA Technical Report: Supplement to Department of
Defense World Geodetic System 1984 Technical Report. Part I and
II. Washington, DC: Defense Mapping Agency.
Method to set the latitude and longitude of the
gPoint object. Longitudes east of the prime meridian (i.e. east
of Greenwich) are positive, longitudes west of the prime meridian
are negative. North latitudes are positive, South latitudes are
negative. $long and $lat should be in decimal degrees.
|$long = $pt->Long(); $lat = $pt->Lat();
Methods to get the values of the Long and Lat properties.
Method to print out the current values of the Long
and Lat properties.
|$pt->setUTM($easting, $northing, [$zone]);
Method to set the easting, northing and optionally
the zone properties of the gPoint. Easting and northing are in decimal
meters. Zone is in ASCII, for example "10S". If zone is
left out then only "local" TM mapping can be performed.
|$easting = $pt->E(); $northing = $pt->N(); $zone
Methods to get the values of the Northing, Easting
and Zone properties.
Method to print out the current values of the Northing,
Easting and Zone properties.
Method to set the easting and northing properties
of the gPoint for the Lambert projection. Easting and northing are
in decimal meters.
|$easting = $pt->lccE(); $northing = $pt->lccN();
Methods to get the values of the Lambert Northing
and Easting properties.
Method to print out the current values of the Lambert
Northing and Easting properties.
| $pt->configLambertProjection ($falseEasting,
$falseNorthing, $longOfOrigin, $latOfOrigin, $firstStdParallel, $secondStdParallel);
This function sets up a number of important parameters
needed to define and calculate a particular Lambert Projection.
$falseEasting & $falseNorthing are just an offset in meters
added to the final coordinate calculated. $longOfOrigin & $LatOfOrigin
are the "center" latitude and longitude of the area being
projected. All coordinates will be calculated in meters relative
to this point on the earth. $firstStdParallel & $secondStdParallel
are the two lines of longitude (that is they run east-west) that
define where the "cone" intersects the earth. Simply put
they should bracket the area being projected.
This method converts Longitude/Latitude values
to UTM. The equations used are from from USGS Bulletin 1532. The
original code upon which this method is based was written in C by
Chuck Gantz- firstname.lastname@example.org and is available at
http://www.gpsy.com/gpsinfo/geotoutm/ along with much additional
UTM coordinates are useful when dealing with paper maps. Basically
the map will can cover a single UTM zone which is 6 degrees on longitude.
So you really don't care about an object crossing two zones. You
just get a second map of the other zone. However, if you happen
to live in a place that straddles two zones (For example the Santa
Barbara area in CA straddles zone 10 and zone 11) Then it can become
a real pain having to have two maps all the time. So relatively
small parts of the world (like say California) create their own
version of UTM coordinates that are adjusted to convert the whole
area of interest on a single map. These are called state grids.
The projection system is the usually same as UTM (i.e. Transverse
Mercator), but the central meridian aka Longitude of Origin is selected
to suit the longitude of the area being mapped (like being moved
to the central meridian of the area) and the grid may cover more
than the 6 degrees of longitude found on a UTM map. Areas that are
wide rather than long - think Montana as an example. May still have
to have a couple of maps to cover the whole state because TM projection
looses accuracy as you move further away from the Longitude of Origin,
15 degrees is usually the limit.
Now, in the case where we want to generate electronic maps that
may be placed pretty much anywhere on the globe we really don't
to deal with the issue of UTM zones in our coordinate system. We
would really just like a grid that is fully contiguous over the
area of the map we are drawing. Similar to the state grid, but local
to the area we are interested in. I call this Local Transverse Mercator
and I have modified the function below to also make this conversion.
If you pass the optional Longitude value to the function as $LongOrigin
then that is the Longitude of Origin that will be used for the projection.
Easting coordinates will be returned (in meters) relative to that
line of longitude - So an Easting coordinate for a point located
East of the longitude of origin will be a positive value in meters,
an Easting coordinate for a point West of the longitude of Origin
will have a negative value in meters. Northings will always be returned
in meters from the equator same as the UTM system. The UTMZone value
will be valid for Long/Lat given - thought it is not meaningful
in the context of Local TM. If a NULL value is passed for $LongOrigin
then the standard UTM coordinates are calculated.
If a value is passed for $longOrigin then the method
assumes that a Local (to the Longitude of Origin passed in) Transverse
Mercator coordinates is to be converted - not a UTM coordinate.
This is the complementary method to the previous one. The function
cannot tell if a set of Northing/Easting coordinates are in the
North or South hemisphere - they just give distance from the equator
not direction - so only northern hemisphere lat/long coordinates
are returned. If you live south of the equator there is a note later
in the code explaining how to have it just return southern hemisphere
This method will convert a Latitude/Longitude coordinate
to an Northing/Easting coordinate on a Lambert Conic Projection.
The configLambertProjection() method should have been called prior
to this one to setup the specific parameters for the projection.
The Northing/Easting parameters calculated are in meters (because
the datum used is in meters) and are relative to the falseNorthing/falseEasting
coordinate. Which in turn is relative to the Lat/Long of origin
The formula were obtained from URL: http://www.ihsenergy.com/epsg/guid7_2.html
but appear to be no longer available at that URL.
The inverse to the previous method.
|$dist = $pt->distanceFrom($lon1, $lat1);
This is a useful method that returns the Great
Circle distance from the gPoint to another Long/Lat coordinate
|$dist = $pt->distanceFromTM(&$pt);
This method also calculates the distance between
this point and another gPoint object. In this case it just uses
Pythagoras's theorem using TM coordinates.
|$pt->gRef($rX, $rY, $rE, $rN, $Scale, $LongOrigin);
This method geo-references a gPoint to a given
map. This means that it calculates the x,y pixel coordinate on the
map that corresponds to the Lat/Long value of the gPoint. A map
is of course just an image file like a jpeg or gif. This method
is quite limited. It assumes that the scale of map is identical
in both X & Y directions; that the map is in the northern hemisphere
and that the 0,0 pixel coordinate is the top left corner of the
You need to know two things about your map image in order to use
this method. First you must know the scale of the map. The scale
is a number in meters per pixel. For example, if your image is 200
pixels wide and the distance it covers is 1000km, then the scale
is (1000x1000)/200 = 5000 meters per pixel. That is, every little
pixel on your image represents a patch of ground 5000 meters wide
and 5000 meters long. The second thing you need is a reference point
on the image. This is a point for which you know both the pixel
coordinate and the latitude/longitude.
First you need to convert the Lat/Long of your reference point
to a Easting/Northing coordinate in a local TM projection. I suggest
you use the Longitude of the reference point as you $LongOrigin
parameter. If you do this then the Easting value of the reference
point will be zero.
The parameters $rX & $rY are the pixel coordinates of the
reference point, these correspond to the parameters $rE & $rN
which are the Northing/Easting coordinate of the same point. The
$Scale parameter is the scale of the map in meters/pixel. The $LongOrigin
parameter is whatever value was used to convert the reference point.