diff --git a/docs/mra-reference.md b/docs/mra-reference.md index 1f571dc2f5cbf074e3d0f81b5b547ab19273ecff..bef8b897364a6727a657f37d39859584ea35f2e8 100644 --- a/docs/mra-reference.md +++ b/docs/mra-reference.md @@ -69,11 +69,11 @@ So a layer is the combination of data (feature type or coverage) plus styling (i Resource | Description ---------|------------ -**GET layers** | Returns a list containing all layers. -**POST layers** | Creates a new layer. -**GET layers/_{l}_** | Returns layer _{l}_. -**PUT layers/_{l}_** | Modifies layer _{l}_. -**DELETE layers/_{l}_** | Deletes layer _{l}_. +[**GET layers**](pages/layers.md#get-layers) | Returns a list containing all layers. +[**POST layers**](pages/layers.md#post-layers) | Creates a new layer. +[**GET layers/_{l}_**](pages/layers.md#get-layersl) | Returns layer _{l}_. +[**PUT layers/_{l}_**](pages/layers.md#put-layersl) | Modifies layer _{l}_. +[**DELETE layers/_{l}_**](pages/layers.md#delete-layersl) | Deletes layer _{l}_. **GET layers/_{l}_/styles** | Returns a list containing all styles associated to layer _{l}_. **DELETE layers/_{l}_/styles/_{s}_** | Removes style _{s}_ from layer _{l}_. **GET layers/_{l}_/fields** | Returns a list containing all fields associated to layer _{l}_. diff --git a/docs/pages/datastores.md b/docs/pages/datastores.md index b31f3a4abebaa9d0714d19f22f752b8101a1de1e..31f4a0dbd1ff30500530292aca8cab269cb07abb 100644 --- a/docs/pages/datastores.md +++ b/docs/pages/datastores.md @@ -1,7 +1,12 @@ -## DataStores +## Data stores & Feature types A data store is a source of spatial data that is vector based. +A data store is a connection to a data source as implied by OGR library. +It could be a shapefile, a PostGIS database or any other data type supported by OGR. + +A feature type is a data set that originates from a data store. + ### GET workspaces/{ws}/datastores @@ -9,38 +14,32 @@ Returns a list containing data stores in workspace. #### Resource URL -http://hostname/workspaces/{ws}/datastores.{extension} +http://hostname/workspaces/{ws}/datastores{.extension} #### Available formats HTML (default value), JSON, XML. -#### Parameters - -None - #### Exemple request -**GET http://hostname/workspaces/my_workspace/datastores.json** +**GET** http://hostname/workspaces/my_workspace/datastores.json -**Status code:** 200 OK +#### Response -**Response:** +**Status code:** `200 OK` -{ - - "dataStores": [ - { - "href": "http://hostname/workspaces/my_workspace/datastores/my_fisrt_datastore.json", - "name": "my_fisrt_datastore" - } - { - "href": "http://hostname/workspaces/my_workspace/datastores/my_second_datastore.json", - "name": "my_second_datastore" - } - ] - -} + { + "dataStores": [ + { + "href": "http://hostname/workspaces/my_workspace/datastores/my_fisrt_datastore.json", + "name": "my_fisrt_datastore" + } + { + "href": "http://hostname/workspaces/my_workspace/datastores/my_second_datastore.json", + "name": "my_second_datastore" + } + ] + } ### POST workspaces/{ws}/datastores @@ -49,21 +48,17 @@ Creates a new data store in workspace. #### Resource URL -http://hostname/workspaces/{ws}/datastores/{ds}.{extension} +http://hostname/workspaces/{ws}/datastores/{ds}{.extension} #### Available formats JSON, XML. -#### Parameters - -None. - #### Example request -**POST http://hostname/workspaces/my_workspace/datastores.json** +**POST** http://hostname/workspaces/my_workspace/datastores.json -**POST Content-type:** `application-json' +**POST Content-type:** `application-json` **POST data:** @@ -82,9 +77,11 @@ None. } } -**Status code:** 201 OK +#### Response + +**Status code:** `201 Created` -**Location:** http://hostname/workspaces/my_workspace/datastores/pg_sample.json +**Location:** `http://hostname/workspaces/my_workspace/datastores/pg_sample.json` ### GET workspaces/{ws}/datastores/{ds} @@ -93,23 +90,19 @@ Returns data store {ds}. #### Resource URL -http://hostname/workspaces/{ws}/datastores/{ds}.{extension} +http://hostname/workspaces/{ws}/datastores/{ds}{.extension} #### Available formats HTML (default value), JSON, XML. -#### Parameters - -None - #### Example request -**GET http://hostname/workspaces/my_workspace/datastores/pg_sample.json +**GET** http://hostname/workspaces/my_workspace/datastores/pg_sample.json -**Status code:** 200 OK +#### Response -**Response:** +**Status code:** `200 OK` { "dataStore": { @@ -140,23 +133,19 @@ Modifies data store {ds}. #### Resource URL -http://hostname/workspaces/{ws}/datastores/{ds}.{extension} +http://hostname/workspaces/{ws}/datastores/{ds}{.extension} #### Available formats JSON, XML. -#### Parameters - -None - #### Example request **PUT http://hostname/workspaces/my_workspace/datastores/pg_sample.json -**PUT Content-type:** `application-json' +**PUT Content-type:** `application-json` -**Response:** +**PUT Data:** { "dataStore": { @@ -173,9 +162,11 @@ None } } -**Status code:** 201 OK +#### Response -**Location:** http://hostname/workspaces/my_workspace/datastores/pg_sample.json +**Status code:** `201 Created` + +**Location:** `http://hostname/workspaces/my_workspace/datastores/pg_sample.json` ### DELETE workspaces/{ws}/datastores/{ds} @@ -184,46 +175,206 @@ Deletes data store {ds}. #### Resource URL -http://hostname/workspaces/{ws}/datastores/{ds}.{extension} +http://hostname/workspaces/{ws}/datastores/{ds}{.extension} #### Available formats JSON, XML. -#### Parameters - -None - #### Example request -**DELETE http://hostname/workspaces/my_workspace/datastores/pg_sample.json +**DELETE** http://hostname/workspaces/my_workspace/datastores/pg_sample.json -**Status code:** 200 OK +#### Response +**Status code:** `200 OK` -### PUT workspaces/{ws}/datastores/{ds}/file.{extension} + +### PUT workspaces/{ws}/datastores/{ds}/file{.extension} Uploads a file from a local source and creates the data store. File must be zipped. #### Resource URL -http://hostname/workspaces/{ws}/datastores/{ds}/file.{extension} +http://hostname/workspaces/{ws}/datastores/{ds}/file{.extension} #### Available formats SHP (ShapeFile). -#### Parameters +#### Example request + +**PUT** http://hostname/workspaces/my_workspace/datastores/ne_110m_admin_0_countries/file.shp + +**PUT Content-type:** `application-zip` + +**PUT binary-data** + +#### Response + +**Status code:** `200 OK` + + +### GET workspaces/{ws}/datastores/{ds}/featuretypes + +Returns all feature type in data store. + +#### Resource URL -None +http://hostname/workspaces/{ws}/datastores/{ds}/featuretypes{.extension} + +#### Available formats + +HTML (default value), JSON, XML. #### Example request -**PUT http://hostname/workspaces/my_workspace/datastores/ne_110m_admin_0_countries/file.shp +**GET** http://hostname/workspaces/my_workspace/datastores/my_datastore/featuretypes.json -**PUT Content-type:** `application-zip' +#### Response -**PUT binary-data** +**Status code:** `200 OK` + + { + "featureTypes": [ + { + "name": "my_first_featuretype", + "href": "http://hostname/workspaces/my_workspace/datastores/my_datastore/featuretypes/my_first_featuretype.json" + }, + { + "name": "my_second_featuretype", + "href": "http://hostname/workspaces/my_workspace/datastores/my_datastore/featuretypes/my_second_featuretype.json" + } + ] + } + +### POST workspaces/{ws}/datastores/{ds}/featuretypes + +Configures a new feature type in data store. The feature type musts exit. + +This operation creates automatically the associated [layer](layers.md#get-layers). + +#### Resource URL + +http://hostname/workspaces/{ws}/datastores/{ds}/featuretypes{.extension} + +#### Available formats + +JSON, XML. + +#### Example request + +**POST** http://hostname/workspaces/my_workspace/datastores/ne_110m_admin_0_countries/featuretypes.json + +**POST Content-type:** `application-json` + +**POST data:** + + { + "featureType": { + "name": "ne_110m_admin_0_countries", + } + } + } + +#### Response + +**Status code:** `201 Created` + +**Location:** http://hostname/workspaces/my_workspace/datastores/ne_110m_admin_0_countries/featuretypes/ne_110m_admin_0_countries.json + + +### GET workspaces/{ws}/datastores/{ds}/featuretypes/{ft} + +Returns the feature type. + +#### Resource URL + +http://hostname/workspaces/{ws}/datastores/{ds}/featuretypes/{ft}{.extension} + +#### Available formats + +JSON, XML. + +#### Example request + +**GET** http://hostname/workspaces/my_workspace/datastores/ne_110m_admin_0_countries/featuretypes/ne_110m_admin_0_countries.json + +#### Response + +**Status code:** `200 OK` + + { + "featureType": { + "nativeBoundingBox": { + "minx": -180, + "miny": -90, + "maxx": 180, + "maxy": 83.64513, + "crs": "EPSG:4326" + }, + "nativeCRS": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AUTHORITY[\"EPSG\",\"4326\"]]", + "latLonBoundingBox": { + "minx": -180, + "miny": -90, + "maxx": 180, + "maxy": 83.64513, + "crs": "EPSG:4326" + }, + "abstract": null, + "nativeName": "ne_110m_admin_0_countries", + "name": "ne_110m_admin_0_countries", + "title": "ne_110m_admin_0_countries", + "enabled": true, + "projectionPolicy": "NONE", + "attributes": [ + { + "length": 4, + "type": "Integer", + "name": "scalerank" + }, + { + "length": 30, + "type": "String", + "name": "featurecla" + }, + { + "length": 16, + "type": "Real", + "name": "labelrank" + }, + // ... + { + "maxOccurs": 1, + "type": "polygon", + "name": "geometry", + "minOccurs": 0 + } + ], + "store": { + "href": "http://hostname/workspaces/my_workspace/datastores/ne_110m_admin_0_countries.json", + "name": "ne_110m_admin_0_countries" + } + } + } + +### DELETE workspaces/{ws}/datastores/{ds}/featuretypes/{ft} + +Removes the configuration of the feature type. + +#### Resource URL + +http://hostname/workspaces/{ws}/datastores/{ds}/featuretypes/{ft}{.extension} + +#### Available formats + +JSON, XML. + +#### Example request + +**DELETE** http://hostname/workspaces/my_workspace/datastores/ne_110m_admin_0_countries/featuretypes/ne_110m_admin_0_countries.json + +#### Response -**Status code:** 200 +**Status code:** `200 OK` diff --git a/docs/pages/layers.md b/docs/pages/layers.md index 30404ce4c54634bf430d2d154c10c45b8b1eebc1..2bf3a1257d4706e4c3005bdcd35cf4c55bbebaf4 100644 --- a/docs/pages/layers.md +++ b/docs/pages/layers.md @@ -1 +1,157 @@ -TODO \ No newline at end of file +## Layers + +A layer is a data resource that could be published by a OGC Web Service. So a layer is the combination of data (feature type or coverage) plus styling (in case of OGC:WMS). + +### GET layers + +Returns a list of all existing layers. + +#### Resource URL + +http://hostname/layers{.extension} + +#### Available formats + +HTML (default value), JSON, XML. + +#### Exemple request + +**GET** http://hostname/layers.json + +#### Response + +**Status code:** `200 OK` + + { + "layers": [ + { + "name": "ne_110m_admin_0_countries", + "href": "http://hostname/layers/ne_110m_admin_0_countries.json" + } + ] + } + + +### POST layers + +Creates a new layers. + +#### Resource URL + +http://hostname/layers{.extension} + +#### Available formats + +HTML (default value), JSON, XML. + +#### Exemple request + +**POST** http://hostname/layers.json + +**POST Content-type:** `application-json` + +**POST data:** + + { + "layer": { + "name": "ne_110m_admin_0_countries", + "resource": { + "href": "http://hostname/workspaces/my_workspace/datastores/ne_110m_admin_0_countries/featuretypes/ne_110m_admin_0_countries.json"} + } + } + +#### Response + +**Status code:** `201 Created` + +**Location:** http://hostname/layer/just_countries.json + + +### GET layers/{l} + +Returns the layer {l}. + +#### Resource URL + +http://hostname/layers/{l}{.extension} + +#### Available formats + +HTML (default value), JSON, XML. + +#### Exemple request + +**GET** http://hostname/layers/ne_110m_admin_0_countries.json + +#### Response + +**Status code:** `200 OK` + + { + "layer": { + "name": "ne_110m_admin_0_countries", + "resource": { + "name": "ne_110m_admin_0_countries", + "href": "http://hostname/workspaces/my_workspace/datastores/ne_110m_admin_0_countries/featuretypes/ne_110m_admin_0_countries.json" + }, + "type": "POLYGON", + "enabled": true + }, + "defaultStyle": { + "href": "http://hostname/styles/default_polygon.json", + "name": "default_polygon" + } + } + + +### PUT layers/{l} + +Modifies the configuration of the layer {l}. + +#### Resource URL + +http://hostname/layers/{l}{.extension} + +#### Available formats + +HTML (default value), JSON, XML. + +#### Exemple request + +**PUT** http://hostname/layers/ne_110m_admin_0_countries.json + +**POST Content-type:** `application-json` + +**POST data:** + + { + "layer": { + "title": "Countries", + "abstract" : "Countries distinguish between metropolitan and independent and semi-independent portions of sovereign states." + } + } + +#### Response + +**Status code:** `200 OK` + + +### DELETE layers/{l} + +Deletes the layer {l}. + +#### Resource URL + +http://hostname/layers/{l}{.extension} + +#### Available formats + +HTML (default value), JSON, XML. + +#### Exemple request + +**DELETE** http://hostname/layers/ne_110m_admin_0_countries.json + +#### Response + +**Status code:** `200 OK` diff --git a/docs/pages/workspaces.md b/docs/pages/workspaces.md index 0b9f70683c42d37aca5cc25f81dd94dfde82a2fc..2b20eba559b3d5d4913e74ab4086c02cadc1b776 100644 --- a/docs/pages/workspaces.md +++ b/docs/pages/workspaces.md @@ -14,17 +14,13 @@ http://hostname/workspaces{.extension} HTML (default value), JSON, XML. -#### Parameters - -None - #### Example request -**GET http://hostname/workspaces.json** +**GET** http://hostname/workspaces.json ##### Response -**Status code:** 200 OK +**Status code:** `200 OK` { "workspaces": [ @@ -47,15 +43,11 @@ http://hostname/workspaces{.extension} JSON, XML. -#### Parameters - -None. - #### Example request -**POST http://hostname/workspaces.json** +**POST** http://hostname/workspaces.json -**POST Content-type:** `application-json' +**POST Content-type:** `application-json` **POST data:** @@ -68,9 +60,9 @@ None. ##### Response -**Status code:** 201 OK +**Status code:** `201 OK` -**Location:** http://hostname/workspaces/my_workspace.json +**Location:** `http://hostname/workspaces/my_workspace.json` ### GET workspaces/{ws} @@ -78,23 +70,19 @@ Returns workspace {ws}. #### Resource URL -http://hostname/workspaces/{ws}.{extension} +http://hostname/workspaces/{ws}{.extension} #### Available formats HTML (default value), JSON, XML. -#### Parameters - -None - #### Example request -**GET http://hostname/workspaces/my_workspace.json** +**GET** http://hostname/workspaces/my_workspace.json ##### Response -**Status code:** 200 OK +**Status code:** `200 OK` { "workspace": { diff --git a/src/server.py b/src/server.py index b1f04e5a98aabd9d936c73a97949163025d60700..130ade4829745527e7031e23858e335dbc84898d 100755 --- a/src/server.py +++ b/src/server.py @@ -1000,6 +1000,7 @@ class layer(object): # update resource if changed href = data.get("resource", {}).get("href") + print href if href: try: ws_name, st_type, st_name, r_type, r_name = mra.href_parse(href, 5)