|
latlon2geocode(lat[, lon])
The latlon2geocode function encodes a given latitude/longitude
coordinate into one long return value. This encoded value can
be indexed and used with a special variant of Texis' BETWEEN
operator for bounded-box searches of a geographical region.
The lat and lon parameters are doubles in the
decimal degrees format (if you have "degrees minutes seconds" (DMS)
format values, you can use dms2dec to convert them). Negative
numbers represent south latitudes and west longitudes, ie. this
function is east-positive (unlike Vortex <geo2code> which
is west-positive).
Valid values for lat are -90 to 90 inclusive. Valid values for
lon are -360 to 360 inclusive. A lon value less than
-180 will have 360 added to it, and a lon value greater than
180 will have 360 subtracted from it. This allows longitude values to
continue to increase or decrease when crossing the International
Dateline, and thus avoid a non-linear "step function". Passing
invalid lat or lon values will return -1. These changes
were added in version 5.01.1193956000 20071101.
In version 5.01.1194667000 20071109 and later, the lon
parameter is optional: both latitude and longitude (in that order) may
be given in a single space- or comma-separated text value for
lat. Also, a N/S suffix (for latitude)
or E/W suffix (for longitude) may be given;
S or W will negate the value.
EXAMPLE
create table geotest(city varchar(64), lat double, lon double,
geocode long);
insert into geotest values('Cleveland', 41.4, -81.5,
latlon2geocode(41.4, -81.5));
For more examples of using latlon2geocode, see the
geocode script in the texis/samples directory.
CAVEATS
The geocode value returned by latlon2geocode is
platform-dependent in format and accuracy; it should not be copied
across platforms. On platforms with 32-bit longs it is accurate
to about 32 seconds (around half a mile, depending on latitude).
-1 is returned for invalid input values (in version 5.01.1193955804 20071101
and later).
NOTES
The geocodes produced by these functions are compatible with the codes
used by the Vortex functions <code2geo> and <geo2code>.
However, the <code2geo> and <geo2code> functions take DMS
format (as described in the dec2dms and dms2dec SQL
functions).
Copyright © Thunderstone Software Last updated: Tue Aug 17 13:27:11 EDT 2010
|