Skip to content

Commit

Permalink
[BIO-6525] Add DBCA spatial autocomplete feature (#10)
Browse files Browse the repository at this point in the history
* [BIO-6525]
Add spatial_data directory and load spatial data for dbca plugin

* Update devcontainer and .gitignore files, and add spatial_data directory with README.md
  • Loading branch information
MarkCalvert authored Feb 26, 2024
1 parent fc203b7 commit d101e65
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@
],
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"python.defaultInterpreterPath": "python",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.analysis.extraPaths": [
"/srv/app/src"
"./app/src/ckan"
],
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ _solr/schema.xml
_src/*
local/*
.env
dbca/

# DBCA
src/
dbca/
spatial_data/*.geojson
5 changes: 5 additions & 0 deletions ckan/docker-entrypoint.d/02_setup_dbca.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ if [[ $CKAN__PLUGINS == *"doi"* ]]; then
ckan -c $CKAN_INI doi initdb
fi

if [[ $CKAN__PLUGINS == *"dbca"* ]]; then
ckan -c $CKAN_INI db upgrade -p dbca
ckan -c $CKAN_INI dbca load_spatial_data
fi

# if [[ $CKAN__PLUGINS == *"harvest"* ]]; then
# ckan -c $CKAN_INI db upgrade -p harvest
# fi
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
- ./src:/srv/app/src_extensions
- ./ckan/config:/srv/app/config
- ckan_logs:/srv/app/logs
- ./spatial_data:/srv/app/spatial_data
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:5000"]
Expand Down
28 changes: 28 additions & 0 deletions spatial_data/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Spatial Data

This directory is used to store GeoJSON files that will be loaded from docker entrypoint file `02_setup_dbca.sh` using the CLI command `ckan -c $CKAN_INI dbca load_spatial_data` if the mapping exists in `ckanext.dbca.spatial_data_mapping`.

## Usage

To add a new GeoJSON file, simply place it in this directory. The container will automatically load the file if there is a corresponding mapping defined in `ckanext.dbca.spatial_data_mapping`.

Please ensure that the GeoJSON file follows the correct format and contains valid spatial data.

## Mapping

The mapping between the GeoJSON files and the data fields in the CKAN database is defined in the `ckanext.dbca.spatial_data_mapping` configuration. Make sure to update the mapping accordingly if you add or modify any GeoJSON files.

Each mapping consists of a filename, layer field, a code field, and a name field.

The mappings are defined as a dictionary where the key is the filename of the GeoJSON file and the value is another dictionary containing the layer, code, and name fields.

Example:
```
{
"ibra.geojson": {"layer": "IBRA Regions", "code":"IWA_REG_CODE_7", "name":"IWA_REG_NAME_7"},
"ibra-sub.geojson": {"layer": "IBRA Subregions)", "code":"IWA_SUB_CODE_7", "name":"IWA_SUB_NAME_7"},
"imcra.geojson": {"layer": "IMCRA Regions", "code": "MESO_ABBR", "name":"MESO_NAME"},
"lga-wa.geojson": {"layer": " Local Government Areas", "code":"LGA_TYPE", "name":"LGA_LGA_NAME"},
"tenure.geojson": {"layer": "DBCA Managed Tenure", "code":"LEG_TENURE", "name":"LEG_NAME"}
}
```

0 comments on commit d101e65

Please sign in to comment.