Geo::GeoNames::Record - Perl module for handling GeoNames.org records
Provides a Perl extension for handling GeoNames.org records.
Xiangrui Meng <mengxr@stanford.edu>
GoeNames: http://www.geonames.org/
This package is part of the metadata generation and remediation suite: http://cads.stanford.edu/
Copyright (C) 2009 by Xiangrui Meng
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
Each Geo::GeoNames::Record instance has the following fields defined in http://download.geonames.org/export/dump/readme.txt:
geonameid : integer id of record in geonames database
name : name of geographical point (utf8) varchar(200)
asciiname : name of geographical point in plain ascii characters, varchar(200)
alternatenames : alternatenames, comma separated varchar(4000) (varchar(5000) for SQL Server)
latitude : latitude in decimal degrees (wgs84)
longitude : longitude in decimal degrees (wgs84)
feature_class : see http://www.geonames.org/export/codes.html, char(1)
feature_code : see http://www.geonames.org/export/codes.html, varchar(10)
country_code : ISO-3166 2-letter country code, 2 characters
cc2 : alternate country codes, comma separated, ISO-3166 2-letter country code, 60 characters
admin1_code : fipscode (subject to change to iso code), isocode for the us and ch, see file admin1Codes.txt for display names of this code; varchar(20)
admin2_code : code for the second administrative division, a county in the US, see file admin2Codes.txt; varchar(80)
admin3_code : code for third level administrative division, varchar(20)
admin4_code : code for fourth level administrative division, varchar(20)
population : bigint (4 byte int)
elevation : in meters, integer
gtopo30 : average elevation of 30'x30' (ca 900mx900m) area in meters, integer
timezone : the timezone id (see file timeZone.txt)
modification_date : date of last modification in yyyy-MM-dd format
For each member variable, we defined a member function to save the curly brackets from your code. For example, you can get the value of $rec->{geonameid} by
$rec->geonameid;
or set its value by
$rec->geonameid = 123456;
We defined several aliases as followed:
id : geonameid;
coordinates : (latitude,longitude);
Constructor for Geo::GeoNames::Record.
my $rec = Geo::GeoNames::Record->new();
It returns an empty Geo::GeoNames::Record object.
my $rec = Geo::GeoNames::Record->new( $str_record );
You may also pass a GeoNames record string. It returns the corresponding Geo::GeoNames::Record object or undef if the input is incorrect.
$rec->parse( $line );
Parses a record line from a GeoNames.org data file and updates the current object.
Returns all unique names.
Returns true if the record has a name matching the $name argument.
Return the country of the record as a Geo::GeoNames::Record object.
Return the admin1 of the record as a Geo::GeoNames::Record object.
Return the admin2 of the record as a Geo::GeoNames::Record object.
Convert the record to a GeoNames.org record line.
Compare records based on their geonameids.
Return true if the record is a country.
Return true if the record is a primary administrative division.
Return true if the record is a second-order administrative division.
To install Geo::GeoNames::Record, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::GeoNames::Record
CPAN shell
perl -MCPAN -e shell install Geo::GeoNames::Record
For more information on module installation, please visit the detailed CPAN module installation guide.