osm api的python包装器
osmapi的Python项目详细描述
osm api的python包装器
文档
文档是使用pdoc生成的,可以是viewed online。
在本地生成文档,您可以使用
pdoc --html osmapi.OsmApi # create HTML file
此项目使用github页面发布其文档。更新 在联机文档中,您需要使用 上述命令并更新此存储库的gh-pages分支。
示例
若要测试此库,请在development server of OpenStreetMap (https://api06.dev.openstreetmap.org)上创建帐户。
阅读openstreetmap
importosmapiapi=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}
构造器
importosmapiapi=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
注意:密码文件中的每一行都应具有 user:密码
写入openstreetmap
importosmapiapi=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()
注
脚本导入和自动编辑只能由 对openstreetmap社区的体验和理解 创建地图,并且只需仔细地planning和consultation 和当地社区一起。
见 Import/Guidelines 以及Automated Edits/Code of Conduct 更多信息。
发展
如果你想帮助开发osmapi,你应该克隆 此存储库和安装要求:
pip install -r requirements.txt pip install -r test-requirements.txt
之后,建议安装flake8pre-commit挂钩:
flake8 --install-hook
测试
要运行测试,请使用以下命令:
nosetests --verbose
通过使用tox,您甚至可以对不同版本的 Python(2.7、3.4、3.5、3.6和3.7):
tox
释放
要创建新版本,请遵循以下步骤(请遵守Semantic Versioning):
- 调整osmapi/__init__.py 中的版本号
- 用版本更新变更日志
- 创建一个pull请求以将development合并到master中(确保 测试通过!)
- 创建一个new release/tag on GitHub(在主机上 分支)
- 那publication on PyPI 通过上的Travis CI发生 每个标记的提交
- 重新构建文档(见上文)并将生成的文件复制到 index.html在gh-pages分支上
归因
这个项目最初是由艾蒂安·乔夫开发的。这个储存库 是SVN原始代码的副本 (http://svn.openstreetmap.org/applications/utils/python_lib/OsmApi/OsmApi.py), 我们的目标是通过github和发布 通过PyPI打包。
另请参见osm wiki:http://wiki.openstreetmap.org/wiki/Osmapi