Git Product home page Git Product logo

osmapi's Introduction

osmapi

Build Coverage Version License

Python wrapper for the OSM API

Installation

Install osmapi from PyPi by using pip:

pip install osmapi

Documentation

The documentation is generated using pdoc and can be viewed online.

The build the documentation locally, you can use

pdoc --html osmapi.OsmApi # create HTML file

This project uses GitHub Pages to publish its documentation. To update the online documentation, you need to re-generate the documentation with the above command and update the gh-pages branch of this repository.

Examples

To test this library, please create an account on the development server of OpenStreetMap (https://api06.dev.openstreetmap.org).

Read from OpenStreetMap

import osmapi
api = osmapi.OsmApi()
print api.NodeGet(123)
# {u'changeset': 532907, u'uid': 14298,
# u'timestamp': u'2007-09-29T09:19:17Z',
# u'lon': 10.790009299999999, u'visible': True,
# u'version': 1, u'user': u'Mede',
# u'lat': 59.9503044, u'tag': {}, u'id': 123}

Constructor

import osmapi
api = osmapi.OsmApi(api="https://api06.dev.openstreetmap.org", username = "you", password = "***")
api = osmapi.OsmApi(username = "you", passwordfile = "/etc/mypasswords")
api = osmapi.OsmApi(passwordfile = "/etc/mypasswords") # if only the passwordfile is specified, the credentials on the first line of the file will be used

Note: Each line in the password file should have the format user:password

Write to OpenStreetMap

import osmapi
api = osmapi.OsmApi(api="https://api06.dev.openstreetmap.org", username = u"metaodi", password = u"*******")
api.ChangesetCreate({u"comment": u"My first test"})
print api.NodeCreate({u"lon":1, u"lat":1, u"tag": {}})
# {u'changeset': 532907, u'lon': 1, u'version': 1, u'lat': 1, u'tag': {}, u'id': 164684}
api.ChangesetClose()

Note

Scripted imports and automated edits should only be carried out by those with experience and understanding of the way the OpenStreetMap community creates maps, and only with careful planning and consultation with the local community.

See the Import/Guidelines and Automated Edits/Code of Conduct for more information.

Development

If you want to help with the development of osmapi, you should clone this repository and install the requirements:

pip install -r requirements.txt
pip install -r test-requirements.txt

After that, it is recommended to install the flake8 pre-commit-hook:

flake8 --install-hook

Tests

To run the tests use the following command:

nosetests --verbose

By using tox you can even run the tests against different versions of python (2.7, 3.3, 3.4, 3.5 and 3.6):

tox

Release

To create a new release, follow these steps (please respect Semantic Versioning):

  1. Adapt the version number in osmapi/__init__.py
  2. Update the CHANGELOG with the version
  3. Create a pull request to merge develop into master (make sure the tests pass!)
  4. Create a new release/tag on GitHub (on the master branch)
  5. The publication on PyPI happens via Travis CI on every tagged commit
  6. Re-build the documentation (see above) and copy the generated file to index.html on the gh-pages branch

Attribution

This project was orginally developed by Etienne Chové. This repository is a copy of the original code from SVN (http://svn.openstreetmap.org/applications/utils/python_lib/OsmApi/OsmApi.py), with the goal to enable easy contribution via GitHub and release of this package via PyPI.

See also the OSM wiki: http://wiki.openstreetmap.org/wiki/Osmapi

osmapi's People

Contributors

metaodi avatar austinhartzheim avatar lilithwittmann avatar michaelvl avatar

Watchers

James Cloos 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.