NAME

Geo::H3::Geo - H3 Geospatial Hexagon Indexing System Geo Object

SYNOPSIS

use Geo::H3::Geo;
my $geo    = Geo::H3::Geo->new(lat=>$lat, lon=>$lon); #isa Geo::H3::Geo
my $h3     = $geo->h3($resolution);                   #isa Geo::H3::Index
my $center = $h3->center;                             #isa Geo::H3::Geo
my $lat    = $center->lat;                            #isa double WGS-84 Decimal Degrees
my $lon    = $center->lon;                            #isa double WGS-84 Decimal Degrees

DESCRIPTION

H3 Geospatial Hexagon Indexing System Geo Object exposes the lat and lon properties as WGS-84 Decimal Degrees and converts coordinates to radians in the struct method for passing into theGeo::H3::FFI API as a Geo::H3::FFI::Struct::GeoCoord object.

The methods h3 and distance are wrappers around select Geo::H3::FFI methods.

CONSTRUCTORS

new

my $geo = Geo::H3::Geo->new(lat => $lat, lon => $lon);

PROPERTIES

lat

Returns the latitude in decimal degrees WGS-84

lon

Returns the longitude in decimal degrees WGS-84

METHODS

struct

Returns the Geo object as an FFI::C struct in the Geo::H3::FFI::Struct::GeoCoord namespace for use in the Geo::H3::FFI API.

h3

Indexes the location at the specified resolution, returning the index object Geo::H3::Index of the cell containing the location.

my $h3 = $geo->h3;    #default resolution is 0
my $h3 = $geo->h3(7); #isa Geo::H3::H3Index

Returns undef on error.

distance

Returns in meters the "great circle" or "haversine" distance between pairs of points (lat/lon pairs).

my $distance = $geoA->distance($geoB); #isa Double

SEE ALSO

Geo::H3, Geo::H3::FFI, Geo::H3::Index, Geo::H3::FFI::Struct::GeoCoord

AUTHOR

Michael R. Davis

COPYRIGHT AND LICENSE

MIT License

Copyright (c) 2021 Michael R. Davis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.