Group
Extension

Matches 17

Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON.pm ( view source; MetaCPAN )
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 ) = @
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/CRS.pm ( view source; MetaCPAN )
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 => 
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/Utils.pm ( view source; MetaCPAN )
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
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/Types.pm ( view source; MetaCPAN )
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'
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/MultiLineString.pm ( view source; MetaCPAN )
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
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/LineString.pm ( view source; MetaCPAN )
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

Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/Point.pm ( view source; MetaCPAN )
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

Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/Feature.pm ( view source; MetaCPAN )
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   => 
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/Base.pm ( view source; MetaCPAN )
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
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/FeatureCollection.pm ( view source; MetaCPAN )
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
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/Role/Geometry.pm ( view source; MetaCPAN )
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
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/MultiPoint.pm ( view source; MetaCPAN )
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

Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/Role/ToJson.pm ( view source; MetaCPAN )
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
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/GeometryCollection.pm ( view source; MetaCPAN )
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
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/Polygon.pm ( view source; MetaCPAN )
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
Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/lib/Geo/JSON/MultiPolygon.pm ( view source; MetaCPAN )
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

Geo-JSON ( M/MJ/MJEMMESON/Geo-JSON-0.007.tar.gz, MJEMMESON, 2015; MetaCPAN )
Geo-JSON/README.pod ( view source; MetaCPAN )
 NAME

Geo::JSON - Perl OO interface for geojson

=head1 VERSION

version 0.005

=head1 SYNOPSIS

    use Geo::JSON;
    
    my $obj = Geo::JSON->from_json( $json );
    
    $obj->to_json();

=head1
 DESCRIPTION

Convert to and from geojson using Perl objects. GeoJSON objects represent
various geographical positions - points, lines, polygons, etc.

Currently in development - feedback welcome.

Cu
arisons, but will
be read-from and written-to.

=head1 GEOJSON SPECIFICATION

See: L<http://www.geojson.org/geojson-spec.html>

=head1 GEOJSON MEMBERS (ATTRIBUTES)

See the specification for the full 

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.