Coder Social home page Coder Social logo

overpex's Introduction

Overpex

Build Status Hex.pm Coverage Status

Simple wrapper for Overpass API.

Installation

Add overpex to your list of dependencies in mix.exs:

def deps do
  [{:overpex, "~> 0.3.1"}]
end

Documentation can be found at https://hexdocs.pm/overpex.

Config

Set the URL for Overpass API in config/config.exs:

config :overpex,
  url: "http://overpass-api.de/api/interpreter"

The default URL is http://overpass-api.de/api/interpreter.

You can also set a timeout in miliseconds:

config :overpex,
  timeout: 10000 # timeout of 10 seconds

The default timeout is 5000 (5 seconds).

Usage

Query for nodes with name Gielgen without the body:

iex> Overpex.query(~s(node["name"="Gielgen"];out skel;))
{:ok,
 %Overpex.Response{nodes: [%Overpex.Node{id: 371597317, lat: 50.7412721,
    lon: 7.192712, tags: []},
   %Overpex.Node{id: 373373733, lat: 50.7290803, lon: 7.2176116, tags: []},
   %Overpex.Node{id: 507464799, lat: 50.739397, lon: 7.1959361, tags: []},
   (...)],
  relations: [], ways: []}}

Query for nodes with name Gielgen with the body:

iex> Overpex.query(~s(node["name"="Gielgen"];out body;))
{:ok,
 %Overpex.Response{nodes: [%Overpex.Node{id: 371597317, lat: 50.7412721,
    lon: 7.192712,
    tags: [%Overpex.Tag{key: "is_in",
      value: "Bonn,Regierungsbezirk Köln,Nordrhein-Westfalen,Bundesrepublik Deutschland,Europe"},
     %Overpex.Tag{key: "name", value: "Gielgen"},
     %Overpex.Tag{key: "place", value: "suburb"}]},
   %Overpex.Node{id: 373373733, lat: 50.7290803, lon: 7.2176116,
    tags: [%Overpex.Tag{key: "name", value: "Gielgen"},
     %Overpex.Tag{key: "shop", value: "bakery"},
     %Overpex.Tag{key: "wheelchair", value: "yes"}]},
   (...)],
  relations: [], ways: []}}

Overpex.Query/1 will automatically parse the response for you. In case you want to get the HTTP response and do the parse yourself, use Overpex.API.query/1:

iex> Overpex.API.query(~s(node["name"="Gielgen"];out skel;))
{:ok, {:xml, "(...)"}}
  
iex> Overpex.API.query(~s([out:json];node["name"="Gielgen"];out skel;))
{:ok, {:json, "(...)"}}

Credits

Inspired by https://github.com/CodeforChemnitz/elixir-overpass

License

The MIT License (MIT)

overpex's People

Contributors

koichirose avatar sergiodottori avatar

Watchers

 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.