Skip to main content

Enhance your development with SmoothGlue™, Map component for providing backend related map APIs.

Project description

SmoothGlue Django Map

A Django app that provides admin-configurable REST APIs for map imagery, terrain providers, and logical entity grouping. Site admins can manage base layers, terrain sources, and group templates (e.g., "Parade Formation") available to frontend map clients without any code changes.

Designed for deployments across diverse networks, including air-gapped environments where public imagery and terrain services are unavailable. When no providers are configured, frontends fall back to Cesium's bundled NaturalEarth imagery and WGS84 Ellipsoid terrain.

Features

  • Imagery Layers — Configure map base-layer providers (ArcGIS, Bing, OpenStreetMap, Cesium Ion, and more) via the Django admin.
  • Terrain Layers — Configure terrain providers (Ellipsoid, Cesium Ion, Cesium Terrain, ArcGIS, Google, VR-TheWorld) via the Django admin.
  • Entity Groups — Group multiple map entities into logical clusters (e.g., Parade Formations) for synchronized frontend operations like multi-drag-and-drop.
  • Group Types — Admin-configurable templates defining standardized nomenclature and iconography for entity groups.
  • Cesium Ion Support — Both imagery and terrain layers support Ion asset IDs for loading layers through the Cesium Ion API.
  • Default Layer — Mark one imagery layer and one terrain layer as the default. The app enforces a single default per layer type automatically.
  • Filterable REST API — Read-only list endpoints with filtering by is_active, is_default, and provider_type.
  • Air-Gap Safe — Ellipsoid terrain (WGS84) requires no network access and is the default terrain provider type.

API Endpoints

Endpoint Description
GET /image-layers/ List active imagery layers
GET /terrain-layers/ List active terrain layers
GET /entity-group-types/ List active group templates
GET /entity-groups/ List active entity groups
POST /entity-groups/ Create a new entity group
DELETE /entity-groups/<id>/ Dissolve an entity group (keeps underlying entities)

List endpoints support query parameters for filtering:

GET /image-layers/?is_default=true
GET /terrain-layers/?provider_type=Cesium+Ion
GET /entity-group-types/?is_active=true

Response Example

{
  "id": "e6227ca5-9e8a-4793-9e63-d8ffa6e858b7",
  "name": "World Imagery",
  "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
  "provider_type": "ArcGis Map Server",
  "ion_asset_id": null,
  "sort_order": 1,
  "is_active": true,
  "is_default": true
}

Orphaned Entity Cleanup (Required Integration)

Because EntityGroup models map generic entities from consuming applications by storing their IDs in a JSONField, the database cannot rely on standard foreign key CASCADE deletions. If an entity is deleted in your consuming application, its ID will become orphaned inside the map group, potentially causing frontend mapping errors.

To prevent this, the package exports a cleanup utility: remove_entities_from_groups. You should trigger this utility inside your app's DRF ViewSet or via a Django post_delete signal whenever a mappable entity is destroyed.

Example using a DRF ViewSet:

from rest_framework import viewsets
from smoothglue.map.utils.entity_group import remove_entities_from_groups

class MyAppEntityViewSet(viewsets.ModelViewSet):
    # ... queryset and serializer ...

    def perform_destroy(self, instance):
        # 1. Clean up the map package groups first
        remove_entities_from_groups(instance.id, auto_dissolve=True)

        # 2. Execute standard deletion
        super().perform_destroy(instance)

(Note: auto_dissolve=True automatically deletes any map group that falls below 2 members after the cleanup).

Installation

Install the Package

pip install smoothglue-django-map

Configure Django

Add the app to INSTALLED_APPS in your settings.py:

INSTALLED_APPS = [
    "smoothglue.map",
    ...,
]

Include the URL routes in your urls.py:

urlpatterns = [
    path("", include("smoothglue.map.urls")),
    ...,
]

Run migrations:

python manage.py migrate

Optionally load the bundled fixtures to seed default imagery and terrain layers:

python manage.py loaddata imagerylayer
python manage.py loaddata terrainlayer

Development

Set Up Virtual Environment

This project uses Poetry for dependency management.

  1. Install Poetry if you haven't already.
  2. Run poetry install to create a virtual environment and install dependencies.

Management Commands

  • makemigrations.py — Generate migrations for the map app.
  • migrate.py — Apply pending migrations.
  • loadtests.py — Run all tests (python3.12 loadtests.py).
  • loaddata.py — Load fixture data (python3.12 loaddata.py smoothglue/map/fixtures/imagerylayer.json).
  • djangoshell.py — Open a Django shell aware of the app.
  • boot_django.py — Bootstraps a standalone Django environment via settings.configure(). Used by the other scripts.

Building

poetry build

This creates source and wheel distributions in the dist/ directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smoothglue_django_map-1.2.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smoothglue_django_map-1.2.0-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file smoothglue_django_map-1.2.0.tar.gz.

File metadata

  • Download URL: smoothglue_django_map-1.2.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.13 Linux/4.18.0-553.97.1.el8_10.x86_64

File hashes

Hashes for smoothglue_django_map-1.2.0.tar.gz
Algorithm Hash digest
SHA256 205f8a1cdde3f6633126743cb176f54b3b12c5f806be9efa4152c73b29ef832c
MD5 438186a1b73ee51f96ea9d51fd3b167f
BLAKE2b-256 2637daa028a6e2c68b7eb55dba7ba05a7ef35f71126fbcdac224abca07d29262

See more details on using hashes here.

File details

Details for the file smoothglue_django_map-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: smoothglue_django_map-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.13 Linux/4.18.0-553.97.1.el8_10.x86_64

File hashes

Hashes for smoothglue_django_map-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a1d6236ddfdcff8c6207c36f49e5be1eedbaf9cf824565bc6bbbe0506f791ca
MD5 5ca64a9eccce92f6693f4ffa8f6c0cfb
BLAKE2b-256 df1528953e23f9899a2276af96b69dbf399325803a4dd7f4fea2a21f37bb8667

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page