Skip to content

Commit

Permalink
adding ckanext-spatial, part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin committed Mar 24, 2023
1 parent aa1735d commit 811f444
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion ckan/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
# 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
5 changes: 4 additions & 1 deletion ckan/ckan.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##############################
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions ckan/extensions/spatial/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions ckan/extensions/spatial/search.html
Original file line number Diff line number Diff line change
@@ -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 %}

0 comments on commit 811f444

Please sign in to comment.