Giter Site home page Giter Site logo

jinagamvasubabu / polyfetcher Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 1.84 MB

Gets the Polygon definitions from OpenStreetMaps and able to combine one or more polygons into one single Multipolygon

Home Page: https://hangoutdude.com/poly_fetcher

Makefile 2.73% Go 97.27%
openstreetmaps polygons multipolygon-shape hacktoberfest

polyfetcher's Introduction

polyfetcher

A Go Package can fetch polygon definitions from OpenStreet maps and it can also combine one or more polygons into one. alt text

Overview

Build Status Go Report Card GoDoc License Visits Badge Maintainability

What it does?

  • It can fetch Polygon definitions from OpenstreetMaps by taking an area name, throw error if the area is not in OSM database
  • Combine one or more polygons into one single Multipolygon

Install

go get github.com/jinagamvasubabu/polyfetcher

How to use Fetch Polygons?

  • get polyfetcher
  go get github.com/jinagamvasubabu/polyfetcher
  • import and use it like below:
  import "github.com/jinagamvasubabu/polyfetcher"
  import "github.com/sirupsen/logrus"
 
  p := polyfetcher.GeometryUtils{}
  resp, err := p.FetchPolygons(context.Background(), []string{"germany", "belgium"})
  fmt.Println(resp)

How to use Combine Polygons?

  • get polyfetcher
  go get github.com/jinagamvasubabu/polyfetcher
  • import and use it like below:
  import "github.com/jinagamvasubabu/polyfetcher"
  import "github.com/sirupsen/logrus"
 
  p := polyfetcher.GeometryUtils{}
  resp, err := p.CombinePolygons(context.Background(), []string{"germany", "belgium"})
  fmt.Println(resp)

Response:

//GeoJson Open street map response structure
type GeoJson struct {
	Name        string        `json:"name"`
	Type        string        `json:"type"`
	Coordinates []interface{} `json:"coordinates"`
}

How to enable Debug logs?

  • Pass logrus LogLevel:logrus.DebugLevel to GeometryUtils struct
  import "github.com/jinagamvasubabu/polyfetcher"

 
  p := polyfetcher.GeometryUtils{LogLevel:logrus.DebugLevel}
  resp, err := p.CombinePolygons(context.Background(), []string{"germany", "belgium"})

How to validate the data ?

Response type is schema.GeoJson, you can marshal the response to string and use geojsonlint to validate the geojson. alt text

Note: If you get an error like Polygons and MultiPolygons should follow the right-hand rule then follow this below article to fix it. https://dev.to/jinagamvasubabu/solution-polygons-and-multipolygons-should-follow-the-right-hand-rule-2c8i

Errors:

  • If one of the area is invalid area then it can fetch the other areas if they are valid
  • If all areas which were passed are invalid then it will throw error error while fetching the polygon

Goroutines Support:

Goroutines support to fetch areas concurrently instead of synchronously

Author

JinagamVasubabu

License

Apache 2.0.

polyfetcher's People

Contributors

jinagamvasubabu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

polyfetcher's Issues

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.