package JSON::WebToken::Constants;
use strict;
use warnings;
use parent qw/Exporter/;
my @error_code = qw/
ERROR_JWT_INVALID_PARAMETER
ERROR_JWT_MISSING_SECRET
ERROR_JWT_INVALID_SEGMENT_
use strict;
use warnings;
package App::JSON::to;
# ABSTRACT: Convert JSON data to various formats
our $VERSION = '1.000';
use JSON::MaybeXS qw<decode_json>;
sub run
{
my ($to, @args) = @_;
d $to;
die "invalid target format '$to'\n"
unless $to =~ /\A[a-z]+\z/ && eval { require "App/JSON/to/$to.pm"; 1 };
my $class = __PACKAGE__ . '::' . $to;
my $obj = $class->can('new') ? $cl
parse options
# GetOptions($obj->options);
binmode(STDIN, ':raw');
my $data = decode_json do { local $/; <STDIN> };
if (my $enc_meth = $obj->can('encoding')) {
binmode(STDOUT, ':enc
use strict;
use warnings;
package App::JSON::to::perl;
our $VERSION = '1.000';
use Data::Dumper ();
sub dump
{
my $data = $_[1];
local $Data::Dumper::Indent = 0;
local $Data::Dumper:
use strict;
use warnings;
package App::JSON::to::yaml;
our $VERSION = '1.000';
use YAML::Tiny ();
sub encoding
{
'UTF-8'
}
sub dump
{
YAML::Tiny->new($_[1])->write_string
}
1;
package Geo::JSON;
our $VERSION = '0.007';
use strict;
use warnings;
use Carp;
use JSON qw/ decode_json /;
use List::Util qw/ first /;
use constant GEOMETRY_OBJECTS => [
qw/ Point MultiPoint L
constant GEOJSON_OBJECTS => [ #
@{ +GEOMETRY_OBJECTS }, qw/ Feature FeatureCollection /
];
our $json = JSON->new->utf8->convert_blessed(1);
sub from_json {
my ( $class, $json ) = @_;
my $data = decode_json($json);
croak "from_json requires a JSON object (hashref)"
unless ref $data eq 'HASH';
return $class->load($data);
}
sub load {
my ( $class, $data ) = @
age Geo::JSON::MultiPoint;
our $VERSION = '0.007';
# ABSTRACT: object representing a geojson MultiPoint
use Moo;
extends 'Geo::JSON::Base';
with 'Geo::JSON::Role::Geometry';
use Geo::JSON::Types -
ons );
1;
__END__
=encoding utf-8
=head1 NAME
Geo::JSON::MultiPoint
=head1 SYNOPSIS
use Geo::JSON::MultiPoint;
my $mpt = Geo::JSON::MultiPoint->new({
coordinates => [ [ 51.50101
],
});
my $json = $mpt->to_json;
=head1 DESCRIPTION
A GeoJSON object with a coordinates attribute consisting of an arrayref of
positions.
See L<Geo::JSON> for more details.
=cut
eo::JSON::MultiLineString;
our $VERSION = '0.007';
# ABSTRACT: object representing a geojson MultiLineString
use Moo;
extends 'Geo::JSON::Base';
with 'Geo::JSON::Role::Geometry';
use Geo::JSON::Ty
}
1;
__END__
=encoding utf-8
=head1 NAME
Geo::JSON::MultiLineString
=head1 SYNOPSIS
use Geo::JSON::MultiLineString;
my $mls = Geo::JSON::MultiLineString->new({
coordinates => [
], ... ],
});
my $json = $mls->to_json;
=head1 DESCRIPTION
A GeoJSON object with a coordinates attribute of an arrayref of
arrayrefs of positions.
See L<Geo::JSON> for more details.
=cut
package Geo::JSON::Utils;
our $VERSION = '0.007';
use strict;
use warnings;
use Carp;
use base 'Exporter';
our @EXPORT_OK = qw/ compare_positions compute_bbox /;
# TODO improve - need to ensure f
NAME
Geo::JSON::Utils - Util methods for Geo::JSON classes
=head1 SYNOPSIS
use Geo::JSON::Utils qw/ compare_positions compute_bbox /;
=head1 DESCRIPTION
Util methods for L<Geo::JSON>
=head1
METHODS
=head2 compare_positions
if (Geo::JSON::Utils::compare_positions( $pt1, $pt2 )) {
# positions of points are the same
}
Compare two points. Compares in up to three dimensions
package Geo::JSON::Role::ToJson;
our $VERSION = '0.007';
# ABSTRACT: Moo::Role providing to_json() methods for a geojson object
use Moo::Role;
sub to_json {
my $self = shift;
my $codec = s
:JSON::json;
return $codec->encode($self);
}
# used by JSON 'convert_blessed'
sub TO_JSON {
return { type => $_[0]->type, %{ $_[0] } };
}
1;
__END__
=encoding utf-8
=head1 NAME
Geo::JSON
e::ToJson
=head1 DESCRIPTION
Provides the C<to_json> method.
=head1 METHODS
=head2 to_json
$point->to_json();
# or with custom JSON codec
$point->to_json( $codec );
Returns JSON str
package Geo::JSON::Base;
our $VERSION = '0.007';
use Moo;
with 'Geo::JSON::Role::ToJson';
use Carp;
use Geo::JSON;
use Geo::JSON::Types -types;
use Geo::JSON::Utils;
use Types::Standard -types;
ercion );
has bbox => ( is => 'rw', isa => Maybe [ ArrayRef [Num] ] );
# used by JSON 'convert_blessed'
sub TO_JSON {
my $self = $_[0];
my %output = (
type => $self->type,
%
eo::JSON::Utils::compute_bbox( shift->all_positions );
}
sub all_positions {
return shift->coordinates;
}
1;
__END__
=encoding utf-8
=head1 NAME
Geo::JSON::Base - Baseclass for Geo::JSON obj
e Geo::JSON::MultiPolygon;
our $VERSION = '0.007';
# ABSTRACT: object representing a geojson MultiPolygon
use Moo;
extends 'Geo::JSON::Base';
with 'Geo::JSON::Role::Geometry';
use Geo::JSON::Types
;
}
1;
__END__
=encoding utf-8
=head1 NAME
Geo::JSON::MultiPolygon
=head1 SYNOPSIS
use Geo::JSON::MultiPolygon;
my $mpol = Geo::JSON::MultiPolygon->new({
coordinates => [
],
},
});
my $json = $mpol->to_json;
=head1 DESCRIPTION
A GeoJSON object with a coordinates of an arrayref of polygon coordinates.
See L<Geo::JSON> for more details.
=cut
age Geo::JSON::Point;
our $VERSION = '0.007';
# ABSTRACT: object representing a geojson Point
use Moo;
extends 'Geo::JSON::Base';
with 'Geo::JSON::Role::Geometry';
use Carp;
use Geo::JSON::Types
1 NAME
Geo::JSON::Point
=head1 SYNOPSIS
use Geo::JSON::Point;
my $pt = Geo::JSON::Point->new({
coordinates => [ 51.50101, -0.14159 ],
});
my $json = $pt->to_json;
=head1 DE
SCRIPTION
A GeoJSON object with a coordinates attribute of a single position.
See L<Geo::JSON> for more details.
=cut
ackage Geo::JSON::Polygon;
our $VERSION = '0.007';
# ABSTRACT: object representing a geojson Polygon
use Moo;
extends 'Geo::JSON::Base';
with 'Geo::JSON::Role::Geometry';
use Geo::JSON::Types -typ
es } ];
}
1;
__END__
=encoding utf-8
=head1 NAME
Geo::JSON::Polygon
=head1 SYNOPSIS
use Geo::JSON::Polygon;
my $pg = Geo::JSON::Polygon->new({
coordinates => [ [ 51.50101, -0.14
159 ], ... ],
[ [ 54.0, 0 ], ... ],
});
my $json = $pg->to_json;
=head1 DESCRIPTION
A GeoJSON object with a coordinates attribute of an arrayref of arrayrefs of
positi
ge Geo::JSON::FeatureCollection;
our $VERSION = '0.007';
use Moo;
extends 'Geo::JSON::Base';
use Carp;
use Types::Standard qw/ ArrayRef HashRef /;
use Geo::JSON::Types -types;
use Geo::JSON::Utils
Geo::JSON::FeatureCollection - object representing a geojson FeatureCollection
=head1 SYNOPSIS
use Geo::JSON::FeatureCollection;
# @feature_objects can be an array of Geo::JSON::Featu
Geo::JSON::Feature objects.
my $fcol = Geo::JSON::FeatureCollection->new({
features => \@feature_objects,
});
my $json = $fcol->to_json;
=head1 DESCRIPTION
A GeoJSON objec
kage Geo::JSON::Feature;
our $VERSION = '0.007';
use Moo;
extends 'Geo::JSON::Base';
use Carp;
use Type::Utils qw( class_type );
use Types::Standard qw/ Str Maybe HashRef /;
use Geo::JSON::Types -
types;
use Geo::JSON::Utils;
has id => ( is => 'ro', isa => Maybe [Str] );
has geometry => (
is => 'ro',
isa => Geometry,
coerce => Geometry->coercion,
required => 1
);
__
=encoding utf-8
=head1 NAME
Geo::JSON::Feature - object representing a geojson Feature
=head1 SYNOPSIS
use Geo::JSON::Feature;
my $ft = Geo::JSON::Feature->new({
geometry =>
package Geo::JSON::Types;
our $VERSION = '0.007';
use strict;
use warnings;
BEGIN {
use Type::Library -base, -declare => qw/
CRS
Feature
Features
Geometry
n
Positions
/;
use Type::Utils;
use Types::Standard -types;
use Geo::JSON::Utils qw/ compare_positions /;
declare Position, #
as ArrayRef [Num], #
("Geo::JSON::Role::Geometry") };
class_type CRS, { class => 'Geo::JSON::CRS' };
class_type Feature, { class => 'Geo::JSON::Feature' };
coerce CRS, from HashRef, q{ 'Geo::JSON::CRS'
package Geo::JSON::GeometryCollection;
our $VERSION = '0.007';
use Moo;
extends 'Geo::JSON::Base';
use Carp;
use Types::Standard qw/ ArrayRef /;
use Geo::JSON::Types -types;
has geometries =>
-8
=head1 NAME
Geo::JSON::GeometryCollection - object representing a geojson GeometryCollection
=head1 SYNOPSIS
use Geo::JSON::GeometryCollection;
my $gcol = Geo::JSON::GeometryCollection-
>new({
geometries => [ ... ],
});
my $json = $mpt->to_json;
=head1 DESCRIPTION
A GeoJSON object with a geometries attribute consisting of an arrayref of
Geometry objects (Point, Mult
package Geo::JSON::CRS;
our $VERSION = '0.007';
use Moo;
with 'Geo::JSON::Role::ToJson';
use Types::Standard qw/ HashRef /;
use Geo::JSON;
has type => (
is => 'ro',
required => 1,
oding utf-8
=head1 NAME
Geo::JSON::CRS - Co-ordinate Reference System object
=head1 SYNOPSIS
use Geo::JSON::CRS;
# A named CRS
my $wgs84 = Geo::JSON::CRS->new(
{ type
s are also possible, e.g. "urn:ogc:def:crs:EPSG::4326"
# A linked CRS
my $crs = Geo::JSON::CRS->new(
{ type => 'link',
properties => {
href =>
package Geo::JSON::LineString;
our $VERSION = '0.007';
use Moo;
extends 'Geo::JSON::Base';
with 'Geo::JSON::Role::Geometry';
use Geo::JSON::Types -types;
has '+coordinates' => ( isa => LineString
=encoding utf-8
=head1 NAME
Geo::JSON::LineString - object representing a geojson LineString
=head1 SYNOPSIS
use Geo::JSON::LineString;
my $ls = Geo::JSON::LineString->new({
coordi
101, -0.14159 ], ... ],
});
my $json = $ls->to_json;
=head1 DESCRIPTION
A GeoJSON object with a coordinates attribute of an arrayref of
positions.
See L<Geo::JSON> for more details.
=cut
package Geo::JSON::Role::Geometry;
our $VERSION = '0.007';
# ABSTRACT: Moo::Role representing behaviour of a geojson Geometry object
use Moo::Role;
use Types::Standard qw/ Any /;
has coordinates
d1 NAME
Geo::JSON::Role::Geometry
=head1 DESCRIPTION
L<Moo::Role> for GeoJSON geometry objects (Point, MultiPoint, LineString,
MultiLineString, Polygon, MultiPolygon).
See L<Geo::JSON> for more de