Giter VIP home page Giter VIP logo

ckanext-geoview's Introduction

ckanext-geoview - Geospatial viewer for CKAN resources

This extension contains view plugins to display geospatial files and services in CKAN. It contains an OpenLayers based viewer originally developed by Philippe Duchesne and other view plugins that used to be part of ckanext-spatial.

Note: This is a work in progress, if you can help with OpenLayers or Leaflet development, check the Issues section for what needs to be done or add a new issue.

This extensions supports CKAN 2.7 onwards, including Python 3 support on CKAN 2.9 or higher.

Installation

To install ckanext-geoview on a production site:

  1. Activate your CKAN virtual environment, for example:

    source /usr/lib/ckan/default/bin/activate
  2. Install the ckanext-geoview Python package into your virtual environment:

    pip install ckanext-geoview
  3. Add the relevant plugins to the ckan.plugins setting in your CKAN config file (by default the config file is located at /etc/ckan/default/production.ini). Check Available plugins to see which ones are available and if they require further configuration.
  4. Add the resource_proxy plugin to the ckan.plugins setting.
  5. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:

    sudo service apache2 reload

Development Installation

To install ckanext-geoview for development:

  1. Clone the source:

    cd /usr/lib/ckan/default/src
    git clone https://github.com/ckan/ckanext-geoview.git
  2. Activate your CKAN virtual environment, for example:

    source /usr/lib/ckan/default/bin/activate
  3. Install the ckanext-geoview Python package into your python virtual environment:

    cd ckanext-geoview
    python setup.py develop
  4. Continue with the main installation instructions above (step 3 onwards).

Available plugins

OpenLayers Viewer

image

The OpenLayers viewer provides access to different geospatial formats and services:

To enable it, add geo_view to your ckan.plugins setting.:

ckan.plugins = ... resource_proxy geo_view

If you want the geospatial views to be created by default, add the plugin to the following setting:

ckan.views.default_views = ... geo_view

The formats and services supported are:

Type Resource format (*)
Web Map Service (WMS) wms
Web Feature Service (WFS) wfs
GeoJSON geojson
GML gml
KML kml
ArcGIS REST API arcgis_rest
Google Fusion Tables gft

(*) Resource formats are case insensitive

Support varies across formats, so you might want to deactivate the ones you are not interested in. To choose which formats to display, set the following configuration option:

ckanext.geoview.ol_viewer.formats = wms kml

To render Google Fusion Tables resources, a Google API Key must be provided in the ini file:

ckanext.geoview.gapi_key = <API Key here>

This key must be granted Fusion Tables permissions. More information on obtaining such a key can be found at https://developers.google.com/fusiontables/docs/v1/using#APIKey.

All configuration options relating to the OpenLayers viewer (ie those prefixed with ckanext.geoview.ol_viewer.*) are passed to the JavaScript module, where they are accessible on the options.ol_config object:

this.ckan.module('olpreview', function (jQuery, _) {

    // ...

    _onReady: function () {


        console.log(this.options.ol_config)

    }

    // ...

}

Other available configuration options are:

  • `ckanext.geoview.ol_viewer.hide_overlays`: if set to True, overlays won't be visible by default (only the base layer)
  • `ckanext.geoview.ol_viewer.default_feature_hoveron`: if set to True, feature data popup will be displayed when hovering on
  • `ckanext.geoview.ol_viewer.forward_ogc_request_params`: if set to True, OGC request parameters that may be present in resource URLs will be kept as part of proxied service requests. If False (default), such parameters will be removed from URL when proxying requests.
Each instance of a view has the following configuration options that can override the global configuration :
  • `feature_hoveron`: if set to True, feature data popup will be displayed when hovering on
  • `feature_style`: JSON representation of an OpenLayers style, as accepted by the StyleMap constructor

Specific basemap support In addition to the basemap types described in Common base layers for Map Widgets, the OpenLayers viewer supports several other basemap types, namely TMS, WMTS, WMS

TMS example (here in Mercator projection) :

ckanext.spatial.common_map.tms.url = <tms URL>
ckanext.spatial.common_map.tms.srs = EPSG:900913
ckanext.spatial.common_map.tms.layername = <TMS layer name>
ckanext.spatial.common_map.tms.resolutions = [156543.03390625,78271.516953125,39135.7584765625,19567.87923828125,9783.939619140625,4891.9698095703125,2445.9849047851562,1222.9924523925781,611.4962261962891,305.74811309814453,152.87405654907226,76.43702827453613,38.218514137268066,19.109257068634033,9.554628534317017,4.777314267158508,2.388657133579254,1.194328566789627,0.5971642833948135,0.29858214169740677,0.14929107084870338,0.07464553542435169,0.037322767712175846,0.018661383856087923,0.009330691928043961,0.004665345964021981,0.0023326729820109904,0.0011663364910054952,5.831682455027476E-4,2.915841227513738E-4,1.457920613756869E-4]
ckanext.spatial.common_map.tms.extent = [-20037508.34, -20037508.34,20037508.34, 20037508.34]

WMTS (in this case parameters will be fetched from online capabilities) :

ckanext.spatial.common_map.type = wmts
ckanext.spatial.common_map.wmts.url = <wmts URL>
ckanext.spatial.common_map.wmts.layer = <WMTS layer name>
ckanext.spatial.common_map.wmts.srs = EPSG:4326

WMS :

ckanext.spatial.common_map.wms.url = <wms URL>
ckanext.spatial.common_map.wms.layer = <layer name>
ckanext.spatial.common_map.wms.srs = EPSG:31370
ckanext.spatial.common_map.wms.extent = [141192.712000, 161464.403000, 158005.472000, 178169.335000]

Multi basemaps

Multiple basemaps can be defined in a separate file, and will result in a dropdown in the interface allowing to switch between basemaps. Basemap definition file is defined as follows :

#ckanext.geoview.basemaps=%(here)s/basemaps.json

(here pointing to a file next to the ini file). This file is a JSON encoded array of basemap definitions reproducing the structure and syntax described above:

[
    {
        "title": "OSM",
        "type" : "custom",
        "url" : "http://tile.openstreetmap.org/{z}/{x}/{y}.png",
        "attribution" : " Map tiles & Data by OpenStreetMap, under CC BY SA."
    },
    {
        "title": "Blue Marble Mercator",
        "type" : "tms",
        "url" : "http://demo.opengeo.org/geoserver/gwc/service/tms/",
        "srs" : "EPSG:900913",
        "layername" : "nasa%3Abluemarble@EPSG%3A900913@png",
        "resolutions" : [156543.03390625,78271.516953125,39135.7584765625,19567.87923828125,9783.939619140625,4891.9698095703125,2445.9849047851562,1222.9924523925781,611.4962261962891,305.74811309814453,152.87405654907226,76.43702827453613,38.218514137268066,19.109257068634033,9.554628534317017,4.777314267158508,2.388657133579254,1.194328566789627,0.5971642833948135,0.29858214169740677,0.14929107084870338,0.07464553542435169,0.037322767712175846,0.018661383856087923,0.009330691928043961,0.004665345964021981,0.0023326729820109904,0.0011663364910054952,5.831682455027476E-4,2.915841227513738E-4,1.457920613756869E-4],
        "extent" : [-20037508.34, -20037508.34,20037508.34, 20037508.34]
    },
    {
        "title": "Blue Marble 4326",
        "type" : "tms",
        "url" : "http://demo.opengeo.org/geoserver/gwc/service/tms/",
        "srs" : "EPSG:4326",
        "layername" : "nasa%3Abluemarble@EPSG%3A4326@png",
        "resolutions" : [0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,6.866455078125E-4,3.4332275390625E-4,1.71661376953125E-4,8.58306884765625E-5,4.291534423828125E-5,2.1457672119140625E-5,1.0728836059570312E-5,5.364418029785156E-6,2.682209014892578E-6,1.341104507446289E-6,6.705522537231445E-7,3.3527612686157227E-7],
        "extent" : [-180,-90,180,90]
    },
    {
        "title": "Opengeo WMS demo",
        "type" : "wms",
        "url" : "http://demo.opengeo.org/geoserver/ows",
        "layer" : "ne:NE1_HR_LC_SR_W_DR",
        "srs" : "EPSG:4326",
        "extent" : [-180,-90,180,90]
    }
]

When declared, this basemap list will override the ckanext.spatial.common_map properties.

URL specification

For WMS and WFS views, the URL must be specified carefully to get the desired result. In general, to browse the offered layers or features of a WMS or WFS endpoint, just specify the endpoint in the URL field of the resource, e.g.:

https://neo.sci.gsfc.nasa.gov/wms/wms

or

http://giswebservices.massgis.state.ma.us/geoserver/wfs

You can request individual layers/features using the "#" sign, e.g.:

https://neo.sci.gsfc.nasa.gov/wms/wms#MOD14A1_M_FIRE

or

http://giswebservices.massgis.state.ma.us/geoserver/wfs#GISDATA.MINLL1_ARC

N.B. For WFS this is the feature name without the qualifier, e.g. GISDATA.MINLL1_ARC and not massgis:GISDATA.MINLL1_ARC in the example above.

Leaflet GeoJSON Viewer

Note: This plugin used to be part of ckanext-spatial.

image

The Leaflet GeoJSON viewer will render GeoJSON files on a map and add a popup showing the features properties, for those resources that have a geojson format.

To enable it, add geojson_view to your ckan.plugins setting.:

ckan.plugins = ... resource_proxy geojson_view

If you want the views to be created by default on all GeoJSON files, add the plugin to the following setting:

ckan.views.default_views = ... geojson_view

You can use the ckanext.geoview.geojson.max_file_size configuration option to define the maximum file size (in bytes) that will be rendered in the map widget. Default is 25 Mb. Note that this relies on the resource size field being set (ie it will only work with uploaded files, not linked externally).

Leaflet WMTS Viewer

image

The Leaflet WMTS viewer will render WMTS (Web Map Tile Service) layers on a map for those resources that have a wmts format.

To enable it, add wmts_view to your ckan.plugins setting.:

ckan.plugins = ... resource_proxy wmts_view

If you want the views to be created by default on all WMTS resources, add the plugin to the following setting:

ckan.views.default_views = ... wmts_view

Leaflet ESRI Shapefile Viewer

image

The Leaflet Shapefile viewer will render ESRI Shapfiles (A ZIP archive contains the .shp, .shx, .dbf, and .prj files) on a map and add a popup showing the features properties, for those resources that have a shp format.

To enable it, add shp_view to your ckan.plugins setting.:

ckan.plugins = ... resource_proxy shp_view

If you want the views to be created by default on all Shapefiles, add the plugin to the following setting:

ckan.views.default_views = ... shp_view

The projection information (EPSG code, e.g., 4326 and 3857) will be loaded if there is a .prj file provided. You can also add a new field named 'resource_crs' in your custom resource fields or the following configuration option (The loading order is: .prj file, 'resource_crs' field, option and EPSG:4326/WGS84):

ckanext.geoview.shp_viewer.srid = 4326

The encoding of the shapefile can be defined by a custom resource field named 'encoding' in the metadata of the dataset or the following configuration option (The loading order is: 'encoding' field, option and UTF-8):

ckanext.geoview.shp_viewer.encoding = UTF-8

Common base layers for Map Widgets

The geospatial view plugins support the same base map configurations than the ckanext-spatial widgets.

Check the following page to learn how to choose a different base map layer:

http://docs.ckan.org/projects/ckanext-spatial/en/latest/map-widgets.html

image

Registering ckanext-geoview on PyPI

ckanext-geoview should be availabe on PyPI as https://pypi.python.org/pypi/ckanext-geoview. If that link doesn't work, then you can register the project on PyPI for the first time by following these steps:

  1. Create a source distribution of the project:

    python setup.py sdist
  2. Register the project:

    python setup.py register
  3. Upload the source distribution to PyPI:

    python setup.py sdist upload
  4. Tag the first release of the project on GitHub with the version number from the setup.py file. For example if the version number in setup.py is 0.0.1 then do:

    git tag 0.0.1
    git push --tags

Releasing a new version of ckanext-geoview

ckanext-geoview is availabe on PyPI as https://pypi.python.org/pypi/ckanext-geoview. To publish a new version to PyPI follow these steps:

  1. Update the version number in the setup.py file. See PEP 440 for how to choose version numbers.
  2. Create a source distribution of the new version:

    python setup.py sdist
  3. Upload the source distribution to PyPI:

    python setup.py sdist upload
  4. Tag the new release of the project on GitHub with the version number from the setup.py file. For example if the version number in setup.py is 0.0.2 then do:

    git tag 0.0.2
    git push --tags

ckanext-geoview's People

Contributors

amercader avatar drnextgis avatar engerrs avatar gallexme avatar jrods avatar letmaik avatar mattfullerton avatar miguelbgouveia avatar pdelboca avatar pduchesne avatar roll avatar smotornyuk avatar torfsen avatar u10313335 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ckanext-geoview's Issues

Use resource views without proxy

I'd like to use resource views of geoview without a proxy, which is ok since I require resources to have proper CORS headers. However, when I disable the resource_proxy extension, the WMS viewer still uses the proxy URL and gets a 404. The GeoJSON viewer uses the correct URL though.

Pip install not installing requirements

Shouldnt Pip Install the requirements in pip-requirements.txt?


DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting ckanext-geoview
  Downloading https://files.pythonhosted.org/packages/e6/48/4e6fa5fe6a12d33440081a0873229bc6e8dbb38f959a6eb98513f166b99a/ckanext-geoview-0.0.16.tar.gz (988kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 993kB 2.1MB/s 
Building wheels for collected packages: ckanext-geoview
  Building wheel for ckanext-geoview (setup.py) ... done
  Created wheel for ckanext-geoview: filename=ckanext_geoview-0.0.16-cp27-none-any.whl size=1041138 sha256=2025eb8c27218ff4fcdef45cd73ea815f1671c0f2e9b42923fe11a70634b4a66
  Stored in directory: /home/user/.cache/pip/wheels/af/fc/00/0baa05a88dee758b515db082ee66e385715e235a8123f02356
Successfully built ckanext-geoview
Installing collected packages: ckanext-geoview
Successfully installed ckanext-geoview-0.0.16

(default) [user@server ckan]$ paster db upgrade -c /etc/ckan/default/production.ini

Traceback (most recent call last):
  File "/usr/lib/ckan/default/bin/paster", line 11, in <module>
    sys.exit(run())
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
    exit_code = runner.run(args)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 236, in run
    result = self.command()
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 357, in command
    self._load_config(cmd!='upgrade')
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 330, in _load_config
    self.site_user = load_config(self.options.config, load_site_user)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 237, in load_config
    load_environment(conf.global_conf, conf.local_conf)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 112, in load_environment
    p.load_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 140, in load_all
    load(*plugins)
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 154, in load
    service = _get_service(plugin)
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 256, in _get_service
    return plugin.load()(name=plugin_name)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/ckanext/geoview/plugin.py", line 7, in <module>
    import ckantoolkit as toolkit
ImportError: No module named ckantoolkit
txt?

 

How are transforms handled?

I was never able to tell how the data was being transformed with the old wms_view extension because there was no base layer. Now, I see that it is offset (for one source slightly, for another it would appear so badly that I see no data in the image).

Example:
https://smartlane.io/dataset/different-geo-visualizations/resource/045d88a8-6a1e-4f41-b23c-fa5efa549d34?view_id=1a3ce747-e55d-4383-b29c-e8ea70f8d70e

(Select Hamburger Autobahn...ohne Verkehrslagedaten) as that should line up with the motorways)

Auto-zoom to visible scale range of WMS layer

As a viewer using GeoView to preview a WMS layer I would like the map to automatically zoom to a scale range so that the WMS layer is visible when the resource preview map is presented.

For example, this resource preview requires the viewer to zoom in until the WMS reaches the draw threshold, where as this resource preview presents the WMS layers at the default small scale used for the map (taken from the layer extent).

The WMS GetCapabilities response may provide MinScaleDenominator and MaxScaleDenominator parameters which specify the draw thresholds for the layer. It is proposed that the GeoView use these parameters if present to ensure the map zooms to a visible scale range for preview.

  • When GetCapabilities returns both a MinScaleDenominator and a MaxScaleDenominator -> select the zoom so that the scale is halfway between.
  • When GetCapabilities presents only the MaxScaleDenominator -> select a scale that is 80% of the MaxScaleDenominator.
  • When only the MinScaleDenominator is present select a scale that is 120% of the MinScaleDenominator

KeyError: 'ckanext'

After install geoview, I see this error in the /var/log/apache2/ckan_default.error.log file:

[Tue Feb 09 13:06:56.078155 2016] [:error] [pid 9319:tid 139956197000960] Error processing line 2 of /usr/lib/ckan/default/lib/python2.7/site-packages/ckanext_geoview-0.0.9-py2.7-nspkg.pth:
[Tue Feb 09 13:06:56.078219 2016] [:error] [pid 9319:tid 139956197000960] 
[Tue Feb 09 13:06:56.078475 2016] [:error] [pid 9319:tid 139956197000960]   Traceback (most recent call last):
[Tue Feb 09 13:06:56.078519 2016] [:error] [pid 9319:tid 139956197000960]     File "/usr/lib/python2.7/site.py", line 158, in addpackage
[Tue Feb 09 13:06:56.078533 2016] [:error] [pid 9319:tid 139956197000960]       exec line
[Tue Feb 09 13:06:56.078559 2016] [:error] [pid 9319:tid 139956197000960]     File "<string>", line 1, in <module>
[Tue Feb 09 13:06:56.078574 2016] [:error] [pid 9319:tid 139956197000960]   KeyError: 'ckanext'
[Tue Feb 09 13:06:56.078586 2016] [:error] [pid 9319:tid 139956197000960] 
[Tue Feb 09 13:06:56.078597 2016] [:error] [pid 9319:tid 139956197000960] Remainder of file ignored

Once this plugin is installed I am unable to install other plugins - the same error gets generated.

No projection definition for code OGC:CRS84

The GeoJSON preview in our CKAN instance has stopped working, the JavaScript console says

uncaught exception: No projection definition for code OGC:CRS84

That seems to be raised by proj4leaflet.

The relevant dataset definitely hasn't changed, and since it had been working before there's something else that I must have modified (although I don't remember what).

I'll look into it.

Not able to get the preview of KML files.

Hi Team

I have installed the extension as per readme, but I am not able to get the preview. No error is coming either in JS or in CKAN. Are there any dependencies that I need to install for ckanext-geoview to work properly.

The preview is completely blank page. Attaching the screenshot for the same.

Loading... The text is coming and after that, it went blank.

screen shot 2018-05-15 at 6 02 15 pm

Thanks

Display features info

GetFeatureInfo for WMS, feature properties for vector formats, similar to the existing one on the GeoJSON view:

preview-geojson

Freeze of the openlayers geoview page for WMTS layers

Here, on loading, for WMTS resources, the openlayers view freezes ("a web page is slowing down your browser"). The whole browser becomes unresponsive, as if there was some infinite loop or similar issue.

The issue happens both on firefox and chrome. It's not completely systematic though, somethings it works well (seems to work better when I have the debug console open, but doesn't work every time still...). Seems to work better also on initial load (as if having the scripts cached by the browser caused issues).

WMS viewer JS error

When trying to view a WMS resource, using http://services.arcgisonline.com/arcgis/rest/Demographics/USE_Population_Density/MapServer/WMTS or other public wms

Uncaught TypeError: Cannot read property 'layers' of undefined(anonymous function) @ ol2_preview.js:5198OpenLayers.Request.GET.success @ ol2_preview.js:5043OpenLayers.Util.extend.runCallbacks @ ol2_preview.js:1871request.onreadystatechange @ ol2_preview.js:1867cXMLHttpRequest.dispatchEvent @ ol2_preview.js:1901fReadyStateChange @ ol2_preview.js:1904_object.onreadystatechange @ ol2_preview.js:1887

OpenLaters Viewer no attribute "resource"

After installing the latest version of ckanext-geoview with OpenLayers Viewer (CKAN 2.8), the server produce the following exception:

2019-10-29 13:54:00,074 ERROR [ckan.config.middleware.flask_app] 'werkzeug.local.LocalProxy object' has no attribute 'resource'
Traceback (most recent call last):
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/ckan/venv/src/ckan/ckan/views/resource.py", line 585, in view
    return h.rendered_resource_view(view, resource, package, embed=True)
  File "/usr/lib/ckan/venv/src/ckan/ckan/lib/helpers.py", line 2303, in rendered_resource_view
    return literal(base.render(template, extra_vars=data_dict))
  File "/usr/lib/ckan/venv/src/ckan/ckan/lib/base.py", line 150, in render
    return flask_render_template(template_name, **extra_vars)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/flask/templating.py", line 140, in render_template
  ...
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/dataviewer/base.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/ckanext/geoview/templates/base.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/venv/src/ckan/ckan/templates/base.html", line 106, in top-level template code
    {%- block page %}{% endblock -%}
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/ckanext/geoview/templates/dataviewer/openlayers2.html", line 9, in block "page"
    data-module-gapi_key="{{ gapi_key or c.resource.gapi_key }}"
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/jinja2/environment.py", line 430, in getattr
    return getattr(obj, attribute)
UndefinedError: 'werkzeug.local.LocalProxy object' has no attribute 'resource'

Improve appearance of ol controls

Hi !

The extension is great, but I find the looks could be improved by :

  • adding the ol.controls.Zoom() (without it, the zoom bar is too abstract)
  • using the normal openlayers layer switcher UI (esp. for the icon and black background, that don't look pro)

Cheers

Add tests

At least that the view/preview is loaded on CKAN 2.2 / 2.3. Ideally some JS ones as well.

Unable to add filters for GeoJson View for the resource

CKAN Version 2.6.2

Steps to reproduce the issue (Actual behavior):

  1. Go to "Dataset" tab of the portal
  2. Create new dataset and add geojson file for that resource (or click on some of the existing datasets with geojson file as a resource)
  3. Click on the geojson file and than click on "Manage" button - Edit Resource Page will be opened
  4. Click on Views tab on the same page
  5. From the Drop down of "New View" button choose "GeoJson" option
  6. Add "Title" for that View, "Description" and try to "Add Filters' for that resource view.
    Result no action was taken when clicking on filters.

Expected behavior: for creating geojson views filter should be added to the view.

Leaflet not handling non EPSG:4326 projections

Proj4Leaflet requires that a projection definition statement is included. Something like:

proj4.defs("EPSG:26910", "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs");

Should be trivial to pull out the projection from the geojson CRS property, but still necessary to find a way to populate the definition with the actual proj4 string.

Openlayers views don't support non-specification of basemap or stamen type as suggested by ckanext-spatial notes on common basemap

In the docs, we're told that geoview supports the same options as the ckanext-spatial map widgets. However, specifying type = stamen does not work because it isn't accounted for in this code:
https://github.com/ckan/ckanext-ghttps://github.com/ckan/ckanext-geoview/blob/master/ckanext/geoview/public/js/ol_preview.js#L113

Also, the handler for no setting (https://github.com/ckan/ckanext-geoview/blob/master/ckanext/geoview/public/js/ol_preview.js#L129) doesn't work because OL_HELPERS.createLayerFromConfig (https://github.com/ckan/ckanext-geoview/blob/master/ckanext/geoview/public/js/ol_preview.js#L138) expects the type to be set:
https://github.com/ckan/ckanext-geoview/blob/master/ckanext/geoview/public/js/vendor/ol-helpers/ol-helpers.js#L1473

...the setting ought to be "XYZ", which is easy to fix, but this leads to the next problem where somewhere else a string is expected instead of an array of URLs. Around this point I gave up and just specified the map fully, and then the preview was fine. I also suspect this would be the easiest solution: say in the docs that the map must be fully specified and include/reference the example from ckanext-spatial for Stamen Watercolour but use Terrain instead as CKAN itself is trying to do.

Support for ArcGIS base layer

As far as I can see, ckanext-geoview supports the visualization of resources of the format arcgis_rest. However, it seems that using an ArcGIS MapServer as the base layer for visualizing resources of other formats (e.g. a separate GeoJSON file) is currently not supported (according to the docs, supported are Stamen, MapBox and custom XYZ URLs).

Is pip extension version up2date?

when I install geoview with pip I'm not sure to install last plugin release. Could you tell me if I'm right or not?
Thanks

Sylvain

Exception on CKAN 2.3

File '/home/adria/dev/pyenvs/ckan_plain/src/ckan/ckan/controllers/package.py', line 1623 in resource_view
  return h.rendered_resource_view(view, resource, package, embed=True)
File '/home/adria/dev/pyenvs/ckan_plain/src/ckan/ckan/lib/helpers.py', line 1757 in rendered_resource_view
  vars = view_plugin.setup_template_variables(context, data_dict) or {}
File '/home/adria/dev/pyenvs/ckan_plain/src/ckanext-geoview/ckanext/geoview/plugin.py', line 152 in setup_template_variables
  p.toolkit.c.resource['proxy_url'] = proxy.get_proxified_resource_url(data_dict)
TypeError: 'str' object does not support item assignment

Local WMS as basemap

I would like to have multi basemap. However, adding a wms doesn't work as it only supports wms version 1.1.1. It seems in the code that if I do not define the version by default it is 1.3. So how in the json file I should indicate the version.
This is at the moment my configuration which doesn't load the wms due to the lack of version support from the wms:
(source: https://geodatenonline.bayern.de/geodatenonline/seiten/wms_dop80cm;jsessionid=EA8846B3A6D4D0418DB558049EB56F8F)
{ "title": "BY WMS", "type" : "wms", "url" : "https://geoservices.bayern.de/wms/v2/ogc_dop80_oa.cgi?", "version" : "1.1.1", "layer" : "by_dop80c", "srs" : "EPSG:4326", "extent" : [-180,-90,180,90] }

In addition, I would like to have mapbox as another basemap. How the configuration should look like? I thought it is there as it is the default basemap for my ckanext-spatial.

Allow custom Leaflet options

Currently it's impossible to change most of the Leaflet options, since they are set automatically based on the more general map options (ckanext.spatial.common_map.*). In my opinion, the options for Leaflet's map should be separately configurable both via the INI:

ckanext.spatial.leaflet.map.zoom = 14
ckanext.spatial.leaflet.map.maxZoom = 16

This would require the support for a corresponding data-module-* attribute in the JS modules, with the additional benefit of being able to change the Leaflet map options for a specific instance of the map (for example, if you're using both the normal preview and ckanext-spatial's dataset extent map and only want to change the configuration of the latter).

CORS issue in OpenLayers 2 viewer

I'm trying to display https://raw.githubusercontent.com/chrisfinch/over9k/master/public/experiments/march-2013/GBR_adm2.json as a GeoJSON resource. In the GeoJSON tab I get the correct map. But in the Map viewer tab which is displayed first (why are there two anyway here?) I get this error in the browser console:

XMLHttpRequest cannot load https://raw.githubusercontent.com/chrisfinch/over9k/master/public/experiments/march-2013/GBR_adm2.json.
Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers in preflight response.

Note that I deliberately do not use resource_proxy since I only want to support resources with proper CORS headers, which in this case above it has.

display WFS features

Hi,
This is a fine extension, thank you for this.
I've managed to display geojson data without problem (well, actually, it took me some time to understand I needed to declare 'geojson' in the format field for it to work), but I am having trouble displaying WFS data.

I'm trying to follow the instructions on https://github.com/ckan/ckanext-geoview#openlayers-viewer and thus, if I understand correctly the instructions, http://webgis.regione.sardegna.it/geoserver/wfs#anagrafe_biblioteche_view should display the anagrafe_biblioteche_view data (dots) on the OL map. But I'm gettinf nothing. Could you tell me what I'm doing wrong ?
Thanks !

Plugin is crashing the harvester

On import phase, the following gets thrown by geoview:

$ paster --plugin=ckanext-harvest harvester import --config /etc/ckan/default/development.ini
/usr/lib/ckan/default/src/ckan/ckan/new_authz.py:6: FutureWarning: ckan.new_authz has been renamed to ckan.authz. The ckan.new_authz module will be removed in a future release.
  FutureWarning)
2015-10-17 09:06:50,410 DEBUG [ckanext.spatial.model.package_extent] Spatial tables defined in memory
2015-10-17 09:06:50,417 DEBUG [ckanext.spatial.model.package_extent] Spatial tables already exist
2015-10-17 09:06:50,431 DEBUG [ckanext.harvest.model] Harvest tables defined in memory
2015-10-17 09:06:50,432 DEBUG [ckanext.harvest.model] Harvest tables already exist

2015-10-17 09:06:50,478 DEBUG [ckanext.harvest.model] Harvest tables already exist
DB tables created
2015-10-17 09:06:50,483 INFO  [ckanext.harvest.logic.action.update] Harvest objects import: {'source_id': None, 'package_id': False, 'harvest_object_id': False}
2015-10-17 09:06:50,494 DEBUG [ckanext.dcat.harvesters.rdf] In DCATRDFHarvester import_stage
/usr/lib/ckan/default/local/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py:79: SAWarning: Usage of the 'related attribute set' operation is not currently supported within the execution stage of the flush process. Results may not be consistent.  Consider using alternative event listeners or connection-level operations instead.
  sess._flush_warning("related attribute set")
2015-10-17 09:06:50,599 DEBUG [ckanext.spatial.plugin] Received: u'{"type": "Polygon", "coordinates": [[[-180.0, -90.0], [180.0, -90.0], [180.0, 90.0], [-180.0, 90.0], [-180.0, -90.0]]]}'
2015-10-17 09:06:50,610 DEBUG [ckanext.spatial.lib] Extent for package 1e85a8ef-efcc-4fa1-a40a-3cc1bec5c8bc unchanged
Traceback (most recent call last):
  File "/usr/lib/ckan/default/bin/paster", line 9, in <module>
    load_entry_point('PasteScript==1.7.5', 'console_scripts', 'paster')()
  File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 104, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 143, in invoke
    exit_code = runner.run(args)
  File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 238, in run
    result = self.command()
  File "/usr/lib/ckan/default/src/ckanext-harvest/ckanext/harvest/commands/harvester.py", line 152, in command
    self.import_stage()
  File "/usr/lib/ckan/default/src/ckanext-harvest/ckanext/harvest/commands/harvester.py", line 325, in import_stage
    'package_id': self.options.package_id,
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 429, in wrapped
    result = _action(context, data_dict, **kw)
  File "/usr/lib/ckan/default/src/ckanext-harvest/ckanext/harvest/logic/action/update.py", line 273, in harvest_objects_import
    harvester.import_stage(obj)
  File "/usr/lib/ckan/default/src/ckanext-dcat/ckanext/dcat/harvesters/rdf.py", line 284, in import_stage
    p.toolkit.get_action('package_update')(context, dataset)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 429, in wrapped
    result = _action(context, data_dict, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/action/update.py", line 371, in package_update
    {'package': data})
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 429, in wrapped
    result = _action(context, data_dict, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/action/create.py", line 468, in package_create_default_resource_views
    create_datastore_views=create_datastore_views)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/datapreview.py", line 303, in add_views_to_dataset_resources
    create_datastore_views)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/datapreview.py", line 261, in add_views_to_resource
    'package': dataset_dict
  File "/usr/lib/ckan/default/src/ckanext-geoview/ckanext/geoview/plugin.py", line 279, in can_view
    format_lower = resource['format'].lower()
KeyError: 'format'

And I have no clue how to recover from that, since none of the clear or purge operations seem to work since the DB entries are now in an inconsistent state somehow. When I try to clear jobs I get:

An error occurred: [(IntegrityError) update or delete on table "package" violates foreign key constraint "harvest_object_package_id_fkey" on table "harvest_object" DETAIL: Key (id)=(1e85a8ef-efcc-4fa1-a40a-3cc1bec5c8bc) is still referenced from table "harvest_object". "begin; \n update package set state = 'to_delete' where id in (select package_id from harvest_object where harvest_source_id = 'fd15d7cd-b576-4577-acbb-7246eee9b41e');\n delete from resource_view where resource_id in (select id from resource where package_id in (select id from package where state = 'to_delete' ));\n delete from resource_revision where package_id in (select id from package where state = 'to_delete' );\n delete from resource where package_id in (select id from package where state = 'to_delete' );\n \n delete from harvest_object_error where harvest_object_id in (select id from harvest_object where harvest_source_id = 'fd15d7cd-b576-4577-acbb-7246eee9b41e');\n delete from harvest_object_extra where harvest_object_id in (select id from harvest_object where harvest_source_id = 'fd15d7cd-b576-4577-acbb-7246eee9b41e');\n delete from harvest_object where harvest_source_id = 'fd15d7cd-b576-4577-acbb-7246eee9b41e';\n delete from harvest_gather_error where harvest_job_id in (select id from harvest_job where source_id = 'fd15d7cd-b576-4577-acbb-7246eee9b41e');\n delete from harvest_job where source_id = 'fd15d7cd-b576-4577-acbb-7246eee9b41e';\n delete from package_role where package_id in (select id from package where state = 'to_delete' );\n delete from user_object_role where id not in (select user_object_role_id from package_role) and context = 'Package';\n delete from package_tag_revision where package_id in (select id from package where state = 'to_delete');\n delete from member_revision where table_id in (select id from package where state = 'to_delete');\n delete from package_extra_revision where package_id in (select id from package where state = 'to_delete');\n delete from package_revision where id in (select id from package where state = 'to_delete');\n delete from package_tag where package_id in (select id from package where state = 'to_delete');\n delete from package_extra where package_id in (select id from package where state = 'to_delete');\n delete from package_relationship_revision where subject_package_id in (select id from package where state = 'to_delete');\n delete from package_relationship_revision where object_package_id in (select id from package where state = 'to_delete');\n delete from package_relationship where subject_package_id in (select id from package where state = 'to_delete');\n delete from package_relationship where object_package_id in (select id from package where state = 'to_delete');\n delete from member where table_id in (select id from package where state = 'to_delete');\n delete from related_dataset where dataset_id in (select id from package where state = 'to_delete');\n delete from related where id in ('');\n delete from package where id in (select id from package where state = 'to_delete');\n commit;\n " {}]

Option to turn off base layer for a view

If we are working with a WMS server that already provides a base layer and/or refuses to supply a base layer with Spherical Mercator projection, there is no way to transform the data to overlay the map. Right now OpenLayers decides to request Spherical Mercator projection anyway which returns XML error messages instead of PNG tiles which can then get plotted as big pink squares.

ckanext.spatial.common_map.subdomains not used?

I am using SSL, so with ckanext-spatial, I needed to use a custom tile server just so I could add the extra two characters in the url :)
I see SSL is now working without the custom server (brilliant!) but I'd like to keep using both extensions for a little while longer and stick with the custom server.

In any case, the problem: I've included the {s} wildcard for subdomains but it isn't getting replaced by one of the characters in ckanext.spatial.common_map.subdomains as used to happen with ckanext-spatial.

MapQuest Discontinued Support

Per this article:
http://devblog.mapquest.com/2016/06/15/modernization-of-mapquest-results-in-changes-to-open-tile-access/

This change seems to cause several, if not all, of the maps generated by this extension to no longer display as expected. Instead, the geo layer still renders over the map as expected but the map tiles are replaced with an image stating:
As of July 11,2016 direct tile access has been discontinued.

Please visit our blog post for more information http://goo.gl/xB0xXt

Have questions?
Contact us:
[email protected]
Visit us:
developer.mapquest.com/forum

I don't think this is an issue with this extension per-say... but is there any plan for remediation to restore functionality here?

Change feature style in OL geoview

Hi,
The doc mentions the possibility to override the StyleMap in the resource's view config. But there is no StyleMap object, as far as I know, in OL4. Could you provide an example of a style override that would work, please ?
Thanks !

URL parameter handling inconsistent with/without proxy

WIth proxy, a WMS URL like
http://services.nationalmap.gov/arcgis/services/nhd/MapServer/WMSServer?request=GetCapabilities&service=WMS
is transformed to
http://services.nationalmap.gov/arcgis/services/nhd/MapServer/WMSServer
before adding the parameters again.

But, when not using the proxy this stripping doesn't happen, so the result is something like:
http://services.nationalmap.gov/arcgis/services/nhd/MapServer/WMSServer?request=GetCapabilities&service=WMS&REQUEST=GetCapabilities&SERVICE=WMS

The only work-around currently is to define the resource url without parameters: http://services.nationalmap.gov/arcgis/services/nhd/MapServer/WMSServer
Otherwise some servers just fail with something like "cannot parse request".

Both scenarios, with and without proxy should behave identically.

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.