Git Product home page Git Product logo

geonames's Introduction

Geonames

Golang parsing library for the geonames.org database dump.

Features

  • Parse data directly without downloading and unzipping
  • Read line by line with low memory consumption

Implemented data

status archive comment
xx.zip GetGeonames; See readme
admin1CodesASCII.txt GetAdminDivisions
admin2Codes.txt GetAdminSubdivisions
adminCode5.zip GetAdminCodes5
allCountries.zip GetGeonames
⚠️ alternateNames.zip depricated, use alternateNamesV2.zip instead
alternateNamesDeletes-xxxx-xx-xx.txt GetAlternateNameDeletes
alternateNamesModifications-xxxx-xx-xx.txt GetAlternateNameModifications
alternateNamesV2.zip GetAlternateNames
alternatenames/xx.zip GetAlternateNames; See readme
cities1000.zip GetGeonames
cities15000.zip GetGeonames
cities500.zip GetGeonames
cities5000.zip GetGeonames
countryInfo.txt GetCountries
deletes-xxxx-xx-xx.txt GetDeletes
featureCodes_bg.txt GetFeatureCodes
featureCodes_en.txt GetFeatureCodes
featureCodes_nb.txt GetFeatureCodes
featureCodes_nn.txt GetFeatureCodes
featureCodes_no.txt GetFeatureCodes
featureCodes_ru.txt GetFeatureCodes
featureCodes_sv.txt GetFeatureCodes
hierarchy.zip GetHierarchy
iso-languagecodes.txt GetLanguages
modifications-xxxx-xx-xx.txt GetModifications
no-country.zip GetGeonames
shapes_all_low.zip GetShapes
⚠️ shapes_simplified_low.json.zip I don't see the point in geojson parsing
timeZones.txt GetTimeZones
userTags.zip GetUserTags

Installation

$ go get github.com/v3v3r3v/geonames

Quick start

Parsing cities

package main

import (
    "fmt"
    "github.com/v3v3r3v/geonames"
    "github.com/v3v3r3v/geonames/models"
    "log"
)

func main() {
    p := geonames.NewParser()
    
    //print all cities with a population greater than 5000
    err := p.GetGeonames(geonames.Cities5000, func(geoname *models.Geoname) error {
    fmt.Println(geoname.Name)
        return nil
    })
    if err != nil {
        log.Fatal(err)
    }
}

Parsing alternames

package main

import (
    "fmt"
    "github.com/v3v3r3v/geonames"
    "github.com/v3v3r3v/geonames/models"
    "log"
)
func main() {
    p := geonames.NewParser()
    
    err := p.GetAlternateNames(geonames.AlternateNames, func(geoname *models.AlternateName) error {
        fmt.Println(geoname.Name)
        return nil
    })
    if err != nil {
        log.Fatal(err)
    }
}

Parsing alphabetical list of archives

package main

import (
    "fmt"
    "github.com/v3v3r3v/geonames"
    "github.com/v3v3r3v/geonames/models"
    "log"
)
func main() {
    p := geonames.NewParser()
    
    err := p.GetGeonames("AD.zip", func(geoname *models.Geoname) error {
        fmt.Println(geoname.Name)
        return nil
    })
    if err != nil {
        log.Fatal(err)
    }
    
    err = p.GetAlternateNames("alternames/AD.zip", func(geoname *models.AlternateName) error {
        fmt.Println(geoname.Name)
        return nil
    })
    if err != nil {
        log.Fatal(err)
    }
}

geonames's People

Contributors

mkrou avatar v3v3r3v avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.