Skip to content

Spatial data management with semantic web technology and Linked Open Data (LOD)

Notifications You must be signed in to change notification settings

JJponciano/SpaLod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spalod Setup Guide

Prerequisites

1. Install Miniconda

You will need Miniconda to manage dependencies and set up your environment. Download and install Miniconda by selecting the appropriate installer for your system (Windows, macOS, or Linux) from here.

After installation, confirm that Conda is installed:

conda --version

2. Set Up the Conda Environment

Once Miniconda is installed, use the provided environment.yml file to create the environment. Alternatively, you can manually create the environment and install dependencies.

Method 1: Using environment.yml

To create the environment directly:

conda env create -f environment.yml

Method 2: Manual Environment Creation

To create the environment manually:

conda create -n spalod_env python=3.10
conda activate spalod_env
pip install django djangorestframework dj-rest-auth social-auth-app-django django-allauth pydeck rdflib pyproj folium shapely laspy

3. Activate the Environment

Activate the Conda environment using:

conda activate spalod_env

Make sure to use the exact environment name if specified differently in the environment.yml file.

Project Setup

  1. With the environment activated, navigate to the project directory and run migrations:
python manage.py makemigrations spalod_app
python manage.py migrate
python manage.py createsuperuser
  1. Start the Django development server:
python manage.py runserver

GraphDB Configuration

Ensure that GraphDB is running and accessible at:

http://localhost:7200/repositories/Spalod

Authentication and API Usage

1. User Registration

Register a new user:

curl -X POST http://127.0.0.1:8000/auth/registration/ -d "username=JJ&password1=GNybRXbC563&password2=GNybRXbC563"

2. User Login

Log in to obtain an authentication token:

curl -X POST http://127.0.0.1:8000/auth/login/ -d "username=JJ&password=GNybRXbC563"

Expected response:

{"key":"9b2b164be957dcfc9dcb399f91acc06d4b0f4228"}

3. Running a SPARQL Query

Example SPARQL query request:

curl -X POST http://127.0.0.1:8000/api/sparql-query/ \
-H "Content-Type: application/json" \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228" \
-d '{"query": "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10"}'

Ontology Update with Property Mappings

To update ontology mappings with new properties and validation timestamps:

curl -X POST http://127.0.0.1:8000/api/update-ontology/ \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228" \
-H "Content-Type: application/json" \
-d '{
      "mappings": [
        {
          "new_property": "http://your-ontology/newProperty1",
          "old_property": "http://your-ontology/oldProperty1"
        },
        {
          "new_property": "http://your-ontology/newProperty2",
          "old_property": "http://your-ontology/oldProperty2"
        }
      ]
    }'

Query Properties

To retrieve properties that have a hasBeenValidatedBy status of "none" or are missing this property:

curl -X GET http://127.0.0.1:8000/api/query-properties/ \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228"

File Upload with Metadata

Example file upload with associated metadata:

curl -X POST http://127.0.0.1:8000/api/upload-file/ \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228" \
-F "file=@/path/to/your/file.json" \
-F "metadata={\"description\": \"This is a shapefile\", \"source\": \"Survey XYZ\"}"

Response:

{
  "message": "File uploaded and ontology processed successfully.",
  "uuid": "04287a39-053d-435e-8064-a7664604edb9",
  "ontology_url": "/media/uploads/04287a39-053d-435e-8064-a7664604edb9/04287a39-053d-435e-8064-a7664604edb9_ontology.owl",
  "map_url": "/media/uploads/04287a39-053d-435e-8064-a7664604edb9/04287a39-053d-435e-8064-a7664604edb9_map.html"
}

To download:

curl -O http://127.0.0.1:8000/media/uploads/04287a39-053d-435e-8064-a7664604edb9/04287a39-053d-435e-8064-a7664604edb9_map.html

Uploading a Point Cloud

curl -X POST http://127.0.0.1:8000/api/upload-file/ \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228" \
-F "file=@/path/to/pointcloud.las" \
-F "metadata={\"description\": \"Pointcloud\", \"source\": \"BKG\"}"

Running SPARQL Queries

Example SPARQL query:

curl -X POST http://localhost:8000/api/sparql-query/ \
-H "Content-Type: application/json" \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228" \
-d '{"query": "PREFIX geo: <http://www.opengis.net/ont/geosparql#> PREFIX ns2: <https://registry.gdi-de.org/id/hamburg/> PREFIX ex: <http://example.org/ns#> SELECT ?feature ?property ?value WHERE { ?feature a geo:Feature ; ?property ?value . }"}'

Miscellaneous Endpoints

Retrieve a Catalog

curl -X GET "http://127.0.0.1:8000/api/geo/catalog?id=http://spalod/catalog_acc53514-6a2f-4521-afa5-40783906d4ba" \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228"

Delete a Catalog

curl -X GET "http://127.0.0.1:8000/api/geo/catalog/delete?id=http://spalod/catalog_acc53514-6a2f-4521-afa5-40783906d4ba" \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228"

Retrieve Feature Information

curl -X GET "http://127.0.0.1:8000/api/geo/feature?id=https://registry.gdi-de.org/feature002755b6-8a27-4e58-a1e7-34635993696e&catalog_id=http://spalod/catalog_652579e3-1a45-4f6d-b55f-c4f1c1bfce20" \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228"

Retrieve WKT of a Feature

curl -X GET "http://127.0.0.1:8000/api/geo/getfeaturewkt?id=https://registry.gdi-de.org/feature002755b6-8a27-4e58-a1e7-34635993696e&catalog_id=http://spalod/catalog_652579e3-1a45-4f6d-b55f-c4f1c1bfce20" \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228"

Retrieve All WKT of All Catalog Features

curl -X GET "http://127.0.0.1:8000/api/geo/getwkt?catalog_id=http://spalod/catalog_652579e3-1a45-4f6d-b55f-c4f1c1bf

ce20" \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228"

Retrieve All Catalogs

curl -X GET "http://127.0.0.1:8000/api/geo/all" \
-H "Authorization: Token 9b2b164be957dcfc9dcb399f91acc06d4b0f4228"