kartoza / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
http://geonode.org/
GNU General Public License v3.0
8 stars 17 forks source link

API to get the Map object. #176

Closed ismailsunni closed 7 years ago

ismailsunni commented 7 years ago

Currently, geonode store map as map model in the django models. The map object contains list of layers in it. There is no API to get this list of layers currently. We need to implement this API to be able to download or add map to QGIS (or another client)

gubuntu commented 7 years ago

Does the model store a list of GeoNode layer names or full WMS urls?

lucernae commented 7 years ago

This is a sample request to:

https://geonode/api/maps

The sample response is:

{
  "geonode_version": "2.7",
  "meta": {
    "limit": 0,
    "offset": 0,
    "total_count": 1
  },
  "objects": [
    {
      "abstract": "test abstract",
      "csw_type": "dataset",
      "csw_wkt_geometry": "POLYGON((-180 -90,-180 90,180 90,180 -90,-180 -90))",
      "date": "2017-05-05T08:07:25.606365",
      "detail_url": "/maps/15",
      "id": 15,
      "layers": [
        {
          "format": null,
          "group": "background",
          "layer_params": "{\"title\": \"OpenMapSurfer Roads\", \"url\": \"http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}\"}",
          "local": false,
          "name": "OpenMapSurfer_Roads",
          "opacity": 1,
          "ows_url": "http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}",
          "source_params": "{}",
          "transparent": false,
          "visibility": true
        },
        {
          "format": null,
          "group": "background",
          "layer_params": "{\"title\": \"OpenStreetMap\", \"url\": \"http://{s}.tile.osm.org/{z}/{x}/{y}.png\"}",
          "local": false,
          "name": "osm",
          "opacity": 1,
          "ows_url": "http://{s}.tile.osm.org/{z}/{x}/{y}.png",
          "source_params": "{}",
          "transparent": false,
          "visibility": false
        },
        {
          "format": null,
          "group": null,
          "layer_params": "{\"url\": \"http://192.168.1.20/qgis-server/ows\", \"title\": \"Airports\"}",
          "local": true,
          "name": "geonode:airports",
          "opacity": 1,
          "ows_url": "http://192.168.1.20/qgis-server/ows",
          "source_params": "{}",
          "transparent": false,
          "visibility": true
        },
        {
          "format": null,
          "group": null,
          "layer_params": "{\"url\": \"http://192.168.1.20/qgis-server/ows\", \"title\": \"Roads\"}",
          "local": true,
          "name": "geonode:roads_osm_4326",
          "opacity": 1,
          "ows_url": "http://192.168.1.20/qgis-server/ows",
          "source_params": "{}",
          "transparent": false,
          "visibility": true
        }
      ],
      "popular_count": 0,
      "rating": 0,
      "share_count": 0,
      "srid": "EPSG:4326",
      "supplemental_information": "No information provided",
      "thumbnail_url": "http://192.168.1.20/uploaded/thumbs/layer-c9615f72-3193-11e7-998a-0242ac110008-thumb.png",
      "title": "Test map",
      "uuid": "c9615f72-3193-11e7-998a-0242ac110008"
    }
  ]
}

Geonode only saved ows_url and group in their model. So, you can get layer that is not a background, and use the OWS Url as regular WMS request.

lucernae commented 7 years ago

This is a sample request against that OWS Url:

LAYERS parameter from name key FORMAT image/png

http://192.168.1.20/qgis-server/ows?SERVICE=WMS&REQUEST=GetMap&VERSION=1.1.1&LAYERS=geonode%3Aairports&STYLES=&FORMAT=image%2Fpng&TRANSPARENT=true&HEIGHT=256&WIDTH=256&SRS=EPSG%3A3857&BBOX=11889932.623815736,-694659.7130556834,11892378.608720861,-692213.7281505561
ismailsunni commented 7 years ago

Is there anything else that we need to do for this?