Giter VIP home page Giter VIP logo

go-geofabrik's Introduction

go-geofabrik

unofficial api client for Geofabrik.

Installation

cli

go install github.com/iwpnd/go-geofabrik/cmd/geofabrik@latest
โžœ geofabrik --help
NAME:
   geofabrik - geofabrik

USAGE:
   geofabrik [global options] command [command options] [arguments...]

COMMANDS:
   md5                  get latest md5 of geofabrik dataset
   polygon              get extent of dataset as geojson feature
   download             download dataset to outputpath
   download-if-changed  download dataset to outputpath if md5 changed
   help, h              Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help

package

MD5

Get latest md5 of a dataset by name

import (
    "contxt"
    "fmt"

    "github.com/iwpnd/go-geofabrik"
    "github.com/iwpnd/rip"
)

func main() {
    g, err := geofabrik.New("http://download.geofabrik.de", false)
    if err != nil {
        panic("wuaah!")
    }

    ctx := context.Background()
    name := "europe/germany/berlin"
    md5, err := g.MD5(ctx, name)
    if err != nil {
        panic(err)
    }
    fmt.Println(md5)
    // >> 379b462358f660744c1a9eed6f46b031
}

Download

Get a dataset by name to output path

import (
    "contxt"
    "fmt"

    "github.com/iwpnd/go-geofabrik"
    "github.com/iwpnd/rip"
)

func main() {
    g, err := geofabrik.New("http://download.geofabrik.de", false)
    if err != nil {
        panic("wuaah!")
    }

    ctx := context.Background()
    name := "europe/germany/berlin"
    outputPath := "./tmp"
    err := g.Download(ctx, name, outputPath)
    if err != nil {
        panic(err)
    }
}

Polygon

Get a dataset extend as Polygon Feature

import (
    "contxt"
    "fmt"

    "github.com/iwpnd/go-geofabrik"
    "github.com/iwpnd/rip"
)

func main() {
    g, err := geofabrik.New("http://download.geofabrik.de", false)
    if err != nil {
        panic("wuaah!")
    }

    ctx := context.Background()
    name := "europe/germany/berlin"
    polygon, err := g.Polygon(ctx, name)
    if err != nil {
        panic(err)
    }
    f, err := polygon.ToFeature()
    if err != nil {
        panic(err)
    }

    fmt.Println(f)
    // > {"type":"Feature"...}
}

License

MIT

Acknowledgement

awesome folks at Geofabrik

Maintainer

Benjamin Ramser - @iwpnd

Project Link: https://github.com/iwpnd/go-geofabrik

go-geofabrik's People

Contributors

dependabot[bot] avatar iwpnd avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.