向geokey项目添加web资源
geokey-webresources的Python项目详细描述
GeoKey网络资源
通过添加web资源扩展geokey项目:geojson和kml。
安装
GeoKey WebResources需要:
- python 2.7版
- GeoKey 1.6或更高版本
从pypi安装geokey webresources:
pip install geokey-webresources
或者从克隆存储库:
cd geokey-webresources
pip install -e .
将软件包添加到已安装的应用程序:
INSTALLED_APPS += (
...
'geokey_webresources',
)
将模型迁移到数据库:
python manage.py migrate geokey_webresources
你现在可以走了!
更新
从pypi更新geokey webresources:
pip install -U geokey-webresources
将新模型迁移到数据库:
python manage.py migrate geokey_webresources
测试
运行测试:
python manage.py test geokey_webresources
检查代码覆盖范围:
pip install coverage
coverage run --source=geokey_webresources manage.py test geokey_webresources
coverage report -m --omit=*/tests/*,*/migrations/*
公共api
获取项目的所有web资源
GET /api/projects/:project_id/webresources/
请求参数:
Parameter | Type | Description |
---|---|---|
project_id | Integer | A unique identifier for the project. |
响应:
响应包含一个web资源数组。如果数组为空,则项目没有活动的Web资源。
[
{
"id": 46,
"status": "active",
"name": "Public Houses",
"description": "All public houses in London.",
"created": "2014-09-19T15:51:32.790Z",
"modified": "2014-09-21T15:51:32.804Z",
"dataformat": "KML",
"url": "http://london.co.uk/public-houses.kml",
"colour": "#000000",
"symbol": null
}
]
响应状态代码:
Code | Reason |
---|---|
200 | The list of web resources has been returned successfully. |
404 | The project was not found (or user has no access to it). |
获取项目的单个web资源
GET /api/projects/:project_id/webresources/:webresource_id/
请求参数:
Parameter | Type | Description |
---|---|---|
project_id | Integer | A unique identifier for the project. |
webresource_id | Integer | A unique identifier for the web resource. |
响应:
{
"id": 46,
"status": "active",
"name": "Train Stations",
"description": "Train stations in Germany.",
"created": "2015-09-15T09:40:01.747Z",
"modified": "2016-01-10T07:12:01.827Z",
"dataformat": "GeoJSON",
"url": "https://germany.de/all-train-stations.geojson",
"colour": "#ffc0cb",
"symbol": '/media/webresources/symbols/train_stations.png'
}
响应状态代码:
Code | Reason |
---|---|
200 | The web resource has been returned successfully. |
404 | The project or web resource was not found. |