NAME
DBIx::Class::InflateColumn::Geo - Inflate geometric columns to data structures
VERSION
Version 0.0100, released 2018-10-27.
SYNOPSIS
package
TheSchema::Result::Park;
__PACKAGE__->load_components(
qw/InflateColumn::Geo/
);
__PACKAGE__->add_columns({
location
=> {
data_type
=>
'point'
},
secondary_location
=> {
data_type
=>
'point'
,
geo_srid
=> 4326,
geo_xname
=>
'longitude'
,
geo_yname
=>
'latitude'
,
geo_with_astext
=> 1,
},
});
Later: my $park = $schema->resultset('Park')->create({ location => { x => 15.43, y => 54.32 }, secondary_location => { longitude => 12.32, latitude => 45.9843 }, }); say $park->location->{'x'}; # 15.43 say $park->secondary_location->{'latitude'}; # 45.9843 say $park->secondary_location->{'astext'}; # POINT(12.32 45.9843)
# Values can also be given as an array ref or as a space-separated string, both in x/longitude, y/latitude order:
my
$same_park
=
$schema
->resultset(
'Park'
)->create({
location
=> [15.43, 54.32],
secondary_location
=>
'12.32 45.9843'
,
});
DESCRIPTION
DBIx::Class::InflateColumn::Geo inflates geometry columns (so far, only POINT
is supported) to more accessible data structures.
COLUMN SPECIFICATION OPTIONS
Usage shown in the synopsis.
geo_srid
The spacial reference identifier you wish to use.
Default: 4326
(aka WGS 84)
Set it to undef
if you want to use your database's default.
geo_xname
The name you wish to use for the X
(or longitude
) value.
Default: x
geo_yname
The name you wish to use for the Y
(or latitude
) value.
Default: y
geo_with_astext
A boolean determining whether the Well-known text of the column is included in the inflated hash. It is not used during deflation.
Default: 0
COMPATIBILITY
I have only tested this on MariaDB 10.*.
SEE ALSO
SOURCE
https://github.com/Csson/p5-DBIx-Class-InflateColumn-Geo
HOMEPAGE
https://metacpan.org/release/DBIx-Class-InflateColumn-Geo
AUTHOR
Erik Carlsson <info@code301.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by Erik Carlsson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.