geonames-lib

Crates.iogeonames-lib
lib.rsgeonames-lib
version0.3.0
sourcesrc
created_at2020-05-15 16:07:01.599807
updated_at2020-05-18 05:03:43.60145
descriptionLibrary for reading format geonames
homepage
repositoryhttps://github.com/koshkin-na/geonames-lib
max_upload_size
id241917
size12,329,490
(koshkin-na)

documentation

README

Rust GeoNames.org Reader

Library for reading format geonames https://www.geonames.org/

Usage

Add this to your Cargo.toml:

[dependencies]
geonames-lib = "0.3.0"

Code:

use std::fs::File;
use std::io::{BufRead, BufReader};
use geonames_lib::model::{GeoName, AlternateName};


fn main() {
    for (index, line) in BufReader::new(File::open("alternateNames.txt").unwrap()).lines().enumerate() {
        let alternate_name = AlternateName::deserialize_from_string(&line.unwrap()).unwrap();
        println!("{:#?}", alternate_name);
        if index > 20 {
            break;
        }
    }

    for (index, line) in BufReader::new(File::open("allCountries.txt").unwrap()).lines().enumerate() {
        let geo_name = GeoName::deserialize_from_string(&line.unwrap()).unwrap();
        println!("{:#?}", geo_name);
        if index > 20 {
            break;
        }
    }
    for (index, line) in BufReader::new(File::open("admin1CodesASCII.txt").unwrap()).lines().enumerate() {
        let admin_code = AdminCode::deserialize_from_string(&line.unwrap()).unwrap();
        println!("{:#?}", admin_code);
        if index > 20 {
          break;
        }
    }
}

Contributing

Contributions welcome! Please fork the repository and open a pull request with your changes.

License

geonames-lib is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT, and COPYRIGHT for details.

Commit count: 6

cargo fmt