|
NAMEGeo::Parse::OSM - OpenStreetMap XML file regexp parser VERSIONversion 0.42 SYNOPSIS use Geo::Parse::OSM;
my $osm = Geo::Parse::OSM->new( 'planet.osm.gz' );
$osm->seek_to_relations;
$osm->parse( sub{ warn $_[0]->{id} if $_[0]->{user} eq 'Alice' } );
METHODSnewCreates parser instance and opens file my $osm = Geo::Parse::OSM->new( 'planet.osm' ); Compressed files (.gz, .bz2) are also supported. parseParses file and executes callback function for every object. Stops parsing if callback returns 'stop' $osm->parse( sub{ warn $_[0]->{id} and return 'stop' } );
It's possible to filter out unnecessary object types $osm->parse( sub{ ... }, only => 'way' );
$osm->parse( sub{ ... }, only => [ 'way', 'relation' ] );
seek_toSeeks to the file position or to the first object of selected type. $osm->seek_to( 0 );
$osm->seek_to( 'way' );
Can be slow on compressed files! seek_to_nodesseek_to_waysseek_to_relations $osm->seek_to_ways; # same as seek_to('way');
parse_fileClass method - creates parser instance and does one parser() pass. Returns created parser object. use Data::Dumper;
Geo::Parse::OSM->parse_file( 'planet.osm', sub{ print Dumper $_[0] } );
FUNCTIONSobject_to_xmlReturns xml representation of the callback object. sub callback {
print Geo::Parse::OSM::object_to_xml( shift @_);
}
Geo::Parse::OSM->parse_file( 'planet.osm', \&callback );
AUTHORliosha, "<liosha at cpan.org>" BUGSPlease report any bugs or feature requests to "bug-geo-parse-osm at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geo-Parse-OSM>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORTYou can find documentation for this module with the perldoc command. perldoc Geo::Parse::OSM You can also look for information at:
ACKNOWLEDGEMENTSLICENSE AND COPYRIGHTCopyright 2010 liosha. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information.
|