From 811f4447992e77ac136f0f61b40f090be2a5ccb3 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 24 Mar 2023 18:29:07 +0100 Subject: [PATCH] adding ckanext-spatial, part 1 --- .env | 5 +++-- ckan/Dockerfile | 16 +++++++++++++- ckan/ckan.ini | 5 ++++- ckan/extensions/spatial/requirements.txt | 9 ++++++++ ckan/extensions/spatial/search.html | 27 ++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 ckan/extensions/spatial/requirements.txt create mode 100644 ckan/extensions/spatial/search.html diff --git a/.env b/.env index 2c766e8e..0dfafca3 100644 --- a/.env +++ b/.env @@ -49,7 +49,7 @@ CKAN_SMTP_MAIL_FROM=ckan@localhost TZ=UTC # Solr -SOLR_IMAGE_VERSION=2.9-solr8 +SOLR_IMAGE_VERSION=2.10-spatial CKAN_SOLR_URL=http://solr:8983/solr/ckan TEST_CKAN_SOLR_URL=http://solr:8983/solr/ckan @@ -70,7 +70,8 @@ NGINX_PORT=80 NGINX_SSLPORT=443 # Extensions -CKAN__PLUGINS="envvars image_view text_view recline_view datastore datapusher" +CKAN__PLUGINS="image_view text_view recline_view datastore datapusher scheming_datasets envvars" +#spatial_metadata spatial_query CKAN__HARVEST__MQ__TYPE=redis CKAN__HARVEST__MQ__HOSTNAME=redis CKAN__HARVEST__MQ__PORT=6379 diff --git a/ckan/Dockerfile b/ckan/Dockerfile index ddc84463..311f3bf1 100644 --- a/ckan/Dockerfile +++ b/ckan/Dockerfile @@ -54,4 +54,18 @@ COPY extensions/add_dataset.html /srv/app/src/ckan/ckan/templates/snippets/add_d # to get them mounted in this image at runtime # Apply any patches needed to CKAN core or any of the built extensions (not the -# runtime mounted ones) \ No newline at end of file +# runtime mounted ones) + +### Spatial ### +#RUN apk add --no-cache python3-dev build-base gdal-dev +RUN pip install --upgrade pip +RUN pip install -e git+https://github.com/ckan/ckanext-spatial.git#egg=ckanext-spatial +RUN apk add geos-dev proj proj-util proj-dev +RUN export PROJ_DIR=/usr/bin +RUN PROJ_DIR=/usr/ pip install pyproj +#RUN pip install pyproj==2.6.1 +#RUN pip3 install -e "git+https://github.com/ckan/ckanext-spatial.git#egg=ckanext-spatial" +#RUN apk add proj proj-util +COPY extensions/spatial/requirements.txt /srv/app/src/ckanext-spatial/requirements.txt +RUN pip3 install -r /srv/app/src/ckanext-spatial/requirements.txt +COPY extensions/spatial/search.html srv/app/src/ckan/ckanext/example_idatasetform/templates/package/search.html \ No newline at end of file diff --git a/ckan/ckan.ini b/ckan/ckan.ini index 2b72dc61..2389eb17 100644 --- a/ckan/ckan.ini +++ b/ckan/ckan.ini @@ -161,7 +161,7 @@ ckan.cors.origin_allow_all = false ckan.cors.origin_whitelist = ## Plugins Settings ############################################################ -ckan.plugins = envvars image_view text_view recline_view datastore datapusher scheming_datasets +ckan.plugins = image_view text_view recline_view datastore datapusher scheming_datasets spatial_metadata spatial_query envvars ckan.resource_proxy.timeout = 5 ## ckanext-scheming ############################## @@ -172,6 +172,9 @@ scheming.dataset_schemas = ckanext.scheming:camel_photos.yaml # will try to load "spatialx_schema.yaml" and "spatialxy_schema.yaml" # as dataset schemas +## ckanext-spatial ################################### +ckanext.spatial.search_backend = solr-bbox + ## Front-End Settings ########################################################## ckan.site_title = Data Catalog by LHM - title ckan.site_description = Data Catalog by LHM - description diff --git a/ckan/extensions/spatial/requirements.txt b/ckan/extensions/spatial/requirements.txt new file mode 100644 index 00000000..741a0aba --- /dev/null +++ b/ckan/extensions/spatial/requirements.txt @@ -0,0 +1,9 @@ +ckantoolkit +Shapely>=1.2.13,<2.0.0 +OWSLib==0.18.0 +lxml>=2.3 +argparse +pyparsing>=2.1.10 +requests>=1.1.0 +six +geojson==2.5.0 \ No newline at end of file diff --git a/ckan/extensions/spatial/search.html b/ckan/extensions/spatial/search.html new file mode 100644 index 00000000..e160723d --- /dev/null +++ b/ckan/extensions/spatial/search.html @@ -0,0 +1,27 @@ +{% ckan_extends %} + +{% block form %} + {% set facets = { + 'fields': fields_grouped, + 'search': search_facets, + 'titles': facet_titles, + 'translated_fields': translated_fields, + 'remove_field': remove_field } + %} + {% set sorting = [ + (_('Relevance'), 'score desc, metadata_modified desc'), + (_('Name Ascending'), 'title_string asc'), + (_('Name Descending'), 'title_string desc'), + (_('Last Modified'), 'metadata_modified desc'), + (_('Custom Field Ascending'), 'custom_text asc'), + (_('Custom Field Descending'), 'custom_text desc'), + (_('Popular'), 'views_recent desc') if g.tracking_enabled else (false, false) ] + %} + {% snippet 'snippets/search_form.html', type='dataset', query=q, sorting=sorting, sorting_selected=sort_by_selected, count=page.item_count, facets=facets, show_empty=request.args, error=query_error %} +{% endblock %} + +{% block secondary_content %} + + {% snippet "spatial/snippets/spatial_query.html" %} + +{% endblock %}