NAME
Geography::NationalGrid::TW - Module to convert Taiwan Datum (TWD67/TM2, TWD97/TM2) to/from Latitude and Longitude
SYNOPSIS
You should _create_ the object using the Geography::NationalGrid factory class, but you still need to know the object interface, given below.
use Geography::NationalGrid;
use Geography::NationalGrid::TW;
# default TWD97
my $point1 = new Geography::NationalGrid::TW(
'Easting' => 302721.36,
'Northing' => 2768851.3995,
);
printf("Point 1 is %f X and %f Y\n", $point1->easting, $point1->northing);
printf("Point 1 is %f N and %f E\n", $point1->latitude, $point1->longitude);
# transform to TWD67
$point1->transform('TWD67');
DESCRIPTION
Once created, the object allows you to retrieve information about the point that the object represents. For example you can create an object using easting / northing and the retrieve the latitude / longitude.
OPTIONS
These are the options accepted in the constructor. You MUST provide either Latitude and Longitude, or Easting and Northing.
- Projection
-
Default is 'TWD97', the "TAIWAN DATUM 97". Another projection recognized is 'TWD67', but only 'TWD97' is tested.
- GridReference
-
There is no grid reference in Taiwan datum. Grid related functions are disabled.
- Latitude
-
The latitude of the point. Actually should be the latitude using the spheroid related to the grid projection but for most purposes the difference is not too great. Specify the amount in any of these ways: as a decimal number of degrees, a reference to an array of three values (i.e. [ $degrees, $minutes, $seconds ]), or as a string of the form '52d 13m 12s'. North is positive degrees, south is negative degrees.
- Longitude
-
As for latitude, except that east is positive degrees, west is negative degrees.
- Easting
-
The number of metres east of the grid origin, using grid east.
- Northing
-
The number of metres north of the grid origin, using grid north.
- Userdata
-
The value of this option is a hash-reference, which you can fill with whatever you want - typical usage might be to specify
Userdata =
{ Name => 'Dublin Observatory' }> but add whatever you want. Access using the data() method.
METHODS
Most of these methods take no arguments. Some are inherited from Geography::NationalGrid
- latitude
-
Returns the latitude of the point in a floating point number of degrees, north being positive.
- longitude
-
As latitude, but east is positive degrees.
- easting
-
How many metres east of the origin the point is. The precision of this value depends on how it was derived, but is truncated to an integer number of metres.
- northing
-
How many metres north of the origin the point is. The precision of this value depends on how it was derived, but is truncated to an integer number of metres.
- deg2string( DEGREES )
-
Given a floating point number of degrees, returns a string of the form '51d 38m 34.34s'. Intended for formatting, like: $self->deg2string( $self->latitude );
- data( PARAMETER_NAME )
-
Returns the item from the Userdata hash whose key is the PARAMETER_NAME.
- transform( PROJECTION )
-
Transform the point to the new projection, i.e. TWD67 to TWD97 or reverse. Return the point after transformation and keep original point intact. Uses the formula proposed by John Hsieh which is supposed to provide 2 meter accuracy conversions.
ACCURACY AND PRECISION
The routines used in this code may not give you completely accurate results for various mathematical and theoretical reasons. In tests the results appeared to be correct, but it may be that under certain conditions the output could be highly inaccurate. It is likely that output accuracy decreases further from the datum, and behaviour is probably divergent outside the intended area of the grid.
This module has been coded in good faith but it may still get things wrong. Hence, it is recommended that this module is used for preliminary calculations only, and that it is NOT used under any circumstance where its lack of accuracy could cause any harm, loss or other problems of any kind. Beware!
REFERENCES
http://wiki.osgeo.org/wiki/Taiwan_datums
John Hsieh - http://gis.thl.ncku.edu.tw/coordtrans/coordtrans.aspx
AUTHOR AND COPYRIGHT
Copyright (c) 2006 Yen-Ming Lee <leeym@leeym.com>
. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.