Skip to content

dataforgoodfr/Coordonnees

Repository files navigation

Coordonnées

Repo structure

This package aims at greatly simplifying the manipulation and transformation of geospatial data and the creation of interactive [map]s from data sources. It is based on 2 inter-dependent modules that are made to work together :

The js folder contains the Javascript part of the project, it is basically a wrapper around MapLibre, which offers a simplified API for JS developers and add some fonctionalities (popups, hovering, events).

The python folder contains the Python part of the project, it is capable of parsing a config format (TODO: define the JSON schema of the config) and automatically pulling data from sources and generating an augmented MapLibre Style Spec file, which can be used by the Javascript module.

Python API

Datapackages

TODO

Map server

You can integrate coordo into any Python web framework.

First create the map object :

from coordo.map import Map

map = Map.from_file(config_file)

Then simply use the .handle_request(path, method, data) to integrate it in your server. Here are some examples :

Flask

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route("/maps/<path:subpath>")
def maps(subpath: str):
    return jsonify(
        map.handle_request(
            request.method,
            subpath,
            request.get_json(),
        )
    )

Django

# views.py
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
import json

@csrf_exempt
def my_map_view(request, subpath):
    return JsonResponse(
        map.handle_request(
            request.method,
            subpath,
            request.body
        )
    )

# urls.py
from django.urls import path
from . import views

urlpatterns = [
    path('map/<path:subpath>/', views.map_view, name='map'),
]

Install from other projects

This repo is still in very early stage so it is not yet published on registries, but you can still install the Python and Javascript packages with the following commands for testing

Python

pip install git+https://github.com/dataforgoodfr/Coordonnees.git#subdirectory=python

Javascript

npm install git+https://github.com/dataforgoodfr/Coordonnees.git

CLI

For development or to quickly test the library

Install

uv venv
uv pip install -e coordo-py
make build

Import data into catalog

AWS_ACCESS_KEY_ID=<access_key_id> AWS_SECRET_ACCESS_KEY=<secret_access_key> aws s3 sync s3://coordonnees-upload ./data --delete --endpoint-url https://s3.fr-par.scw.cloud --region fr-par
make catalog

Serve a config file

uv run coordo serve data/config.json

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors