++ed by:
1 non-PAUSE user
Author image Xiangrui Meng

NAME

Geo::GeoNames::Record - Perl module for handling GeoNames.org records

DESCRIPTION

Provides a Perl extension for handling GeoNames.org records.

AUTHOR

Xiangrui Meng <mengxr@stanford.edu>

LINKS

GoeNames: http://www.geonames.org/

This package is part of the metadata generation and remediation suite: http://cads.stanford.edu/

COPYRIGHT

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.

VARIABLES

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;

VARIABLE ALIASES

We defined several aliases as followed:

id : geonameid;

coordinates : (latitude,longitude);

METHODS

new()

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.

parse()
    $rec->parse( $line );

Parses a record line from a GeoNames.org data file and updates the current object.

names()

Returns all unique names.

has_name( $name )

Returns true if the record has a name matching the $name argument.

country()

Return the country of the record as a Geo::GeoNames::Record object.

admin1()

Return the admin1 of the record as a Geo::GeoNames::Record object.

admin2

Return the admin2 of the record as a Geo::GeoNames::Record object.

as_string()

Convert the record to a GeoNames.org record line.

op_eq()

Compare records based on their geonameids.

is_country()

Return true if the record is a country.

is_admin1()

Return true if the record is a primary administrative division.

is_admin2()

Return true if the record is a second-order administrative division.