DBIx::Class::InflateColumn::Geo - Inflate geometric columns to data structures
Version 0.0100, released 2018-10-27.
package TheSchema::Result::Park; use base 'DBIx::Class::Core'; __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', });
DBIx::Class::InflateColumn::Geo inflates geometry columns (so far, only POINT is supported) to more accessible data structures.
POINT
Usage shown in the synopsis.
The spacial reference identifier you wish to use.
Default: 4326 (aka WGS 84)
4326
Set it to undef if you want to use your database's default.
undef
The name you wish to use for the X (or longitude) value.
X
longitude
Default: x
x
The name you wish to use for the Y (or latitude) value.
Y
latitude
Default: y
y
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
0
I have only tested this on MariaDB 10.*.
DBIx::Class::GeomColumns
https://github.com/Csson/p5-DBIx-Class-InflateColumn-Geo
https://metacpan.org/release/DBIx-Class-InflateColumn-Geo
Erik Carlsson <info@code301.com>
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.
To install DBIx::Class::InflateColumn::Geo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::InflateColumn::Geo
CPAN shell
perl -MCPAN -e shell install DBIx::Class::InflateColumn::Geo
For more information on module installation, please visit the detailed CPAN module installation guide.