### ----------------------------------------------------
### -- Geo::Basic
### -- Licenses: Artistic-1.0-Perl
### -- Authors: Brian Duggan
### -- File: t/04-quadkey.rakutest
### ----------------------------------------------------
#!raku

use Geo::Basic;
use Test;

my $b = quadkey-decode('032001022');

is-approx $b<lat-min>,  38.822590, 'lat-min';
is-approx $b<lat-max>,  39.368279, 'lat-max';
is-approx $b<lon-min>, -84.375000, 'lon-min';
is-approx $b<lon-max>, -83.671875, 'lon-max';

my $encoded = quadkey-encode(lat => 39.368279, lon => -83.671875, zoom => 8);
is $encoded, '03200102', 'latlon-to-quadkey';

my $geojson = bounds-to-geojson {
    lat-min => 38.822590,
    lat-max => 39.368279,
    lon-min => -84.375000,
    lon-max => -83.671875
};

is $geojson<type>, 'Polygon', 'geojson type';

is $geojson<coordinates>, [
    [ [ -84.375000, 38.822590 ],
      [ -83.671875, 38.822590 ],
      [ -83.671875, 39.368279 ],
      [ -84.375000, 39.368279 ],
      [ -84.375000, 38.822590 ] ],
], 'geojson coordinates';

my $g = quadkey-decode('032001022', :geojson);
ok $g<type> eq 'Polygon', 'geojson type when sending named parameter';

done-testing;



