Geo::OSM::Primitive - Abstract base classes for the three Open Street Map primitives: node, way and relation.

SYNOPSIS

OVERVIEW

The idea is to encapsulte methods that use OpenStreetMap data (that is possibly stored in Geo::OSM::DBI.

METHODS

new

new($osm_id, $primitive_type);

primitive_type

my $type = $osm_primitive->primitive_type();

if ($type eq 'way') {
   …
}
elsif ($type eq 'nod') {
   …
}
elsif ($type eq 'rel') {
   …
}

Returns the type of the primitive: 'nod' (sic!) if the primitive is a <node>, 'way' if the primitive is a <way> or 'rel' if the primitive is a <relation>.

member_of

if ($osm_primitive->member_of($rel)) { …
}

Tests whether the primitive is a member of the relation $rel. (TODO: currently only checks the cache. If the membership is not found in the cache, it is not further checked for its existence. That should of course be fixed once).

role

my $role = $osm_primitive->role($osm_relation);

Returns the role of $osm_relation in <relation> <$osm_relation>. (TODO: currently only works if the role had been set with "_set_cache_role". Of course, the role should also be found if it is not in the cache.).

_set_cache_role

my $role = 'outer';
$osm_primitive->_set_cache_role($osm_relation, $role);

This method assumes that the primitive on which it is called is a member of $osm_relation (which must be a Geo::OSM::Primitive::Relation) and that the role (which is a string) is $role.

This method is internal and should not be called from a user of Geo::OSM::DBI.

AUTHOR

René Nyffenegger

SEE ALSO

Geo::OSM::Render is a base class to render osm data. Geo::OSM::Render::SVG is a derivation of that base class to render SVG files.

Geo::OSM::DBI can be used to store Open Street Map data in a database. (It should be database independant (hence DBI), yet currently, it probably only works with SQLite.

COPYRIGHT AND LICENSE Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at: http://www.perlfoundation.org/artistic_license_2_0

Source Code

The source code is on github. Meaningful pull requests are welcome.