This repo is built directly on top of the Sketchmapia Microservices framework developed by the Spatial Intelligence Lab (SIL) at the Institute for Geoinformatics (IFGI) in University of Münster.
It also builds on top of the existing GMDA-Feature, reusing the 8-point MBR(Minimum Bounding Rectangle) extraction and 1:1 alignment logic as the shared foundation.
Bi-Dimensional Regression (BDR) is a statistical technique for comparing the configural similarity between two 2D sets of points - which is commonly used in cognitive mapping research to assess how well a SketchMap's layout is matching to the corresponding BaseMap. It generalizes ordinary least-squares regression from one dimension to two, and fitting a similarity transform(uniform scale, rotation, and translation) that best maps one configuration of points onto the other, then it measures how much residual error remains after that transform.
This implementation fits a similarity transform between paired BaseMap and SketchMap points (via skimage.transform.SimilarityTransform) and reports the transform parameters alongside a goodness-of-fit and distortion score.
This feature was also discussed and used in the foundational research paper presented in:
- Reuses GMDA's Alignment Pipeline:
Uses the same 8 peripheral MBR points per feature and the same SketchAlign/aligned property-based matching as GMDA, so both metrics operate on a consistent, strictly 1:1 aligned feature set.
- Similarity Transform Fitting:
Estimates a single similarity transform (scale phi, rotation theta, translation alpha1/alpha2) that best maps base-map points onto sketch-map points using least-squares.
- Dual Feature Support:
Provided as two independent calculators — one for landmark polygons/points, one for street-junction points — following the same Landmarks/Junctions split as GMDA.
- Automatic Junction Detection:
For the junctions calculator, junctions are detected directly from line-segment endpoints that coincide across two or more roads, then matched between base map and sketch map using a topological subset check on shared road IDs.
Both endpoints return the same four core measures, derived from the fitted similarity transform:
- Bidimensional Correlation (r):
Measures how well the fitted transform explains the sketch-map point positions, analogous to a 2D R². Computed from the residual sum of squares between the transform's predicted points and the actual sketch-map points, relative to the total variance of the sketch-map points.
- Distortion Index (DI):
A percentage-scale measure of how much the sketch map's configuration deviates from a perfect similarity-transformed copy of the base map. Derived directly from r.
- Scale Factor (phi):
The uniform scale factor of the fitted similarity transform — how much larger or smaller the sketch map's layout is relative to the base map.
- Rotation (theta):
The rotation angle (in degrees) of the fitted similarity transform, indicating systematic rotational skew between the sketch map and the base map.
- Translation (alpha1, alpha2):
The x/y translation offset of the fitted similarity transform.
- BDR Calculator (Landmark Based): Calculates the four BDR measures using polygon/point features (landmarks) from the generalized base map and sketch map.
How it works?
- After running Analyse, the generalized base map and processed sketchmap are available in the frontend.
- Checking Calculate BDR for Landmarks sends both maps as GeoJSON to the bdr microservice via a POST request to /bdr/calculateLandmarksBDR/.
- The backend filters both maps down to strictly 1:1 aligned polygon/point features (via the
alignedandSketchAlignproperties, same as GMDA), builds 8-point MBRs for each, and fits a similarity transform mapping base-map MBR points onto sketch-map MBR points. - The four metrics are computed from the fitted transform and returned as JSON.
- Results are written into the Landmarks BDR columns of the main results table.
- Junction Based BDR Calculator: Calculates the four BDR measures using street-junction points from both maps.
How it works?
- After running Analyse, checking Calculate BDR for Junctions sends both maps as GeoJSON to /bdr/calculateJunctionsBDR/.
- The backend detects junctions on both maps by finding line-segment endpoints shared by two or more roads.
- Junctions are matched between maps using a topological subset check: a sketch-map junction matches a base-map junction if all road IDs at the sketch junction are a subset of the road IDs at the base junction.
- MBR points for matched junction pairs are used to fit the similarity transform, and the four metrics are computed and returned.
- Results are written into the Junctions BDR columns of the main results table.
A new Django microservice was added following the same architecture as the existing services (completeness, accuracy, generalizations, gmda).
bdr/
├── Dockerfile # runs on port 8006
├── requirements.txt # Django, numpy, geopandas, scikit-image, scikit-learn
├── manage.py
├── bdr/
│ ├── settings.py
│ ├── urls.py # routes /bdr/ to microservice/urls.py
│ ├── wsgi.py
│ └── asgi.py
└── microservice/
├── urls.py
# maps endpoints to views
└── views.py # all BDR logic lives here
| Endpoint | Method | Description |
|---|---|---|
/bdr/calculateLandmarksBDR/ |
POST | Landmark-based BDR |
/bdr/calculateJunctionsBDR/ |
POST | Junction-based BDR |
POST /bdr/calculateLandmarksBDR/
Content-Type: application/x-www-form-urlencoded
basemapdata=[GeoJSON string]&sketchmapdata=[GeoJSON string]
{
"r": 0.9714,
"DI": 23.7332,
"phi": 0.8063,
"theta": 26.6147,
"alpha1": 243.0352,
"alpha2": -69.226
}| File | Change |
|---|---|
docker-compose.yml |
Added bdr service on port 8006. |
sketchmap_analyser/static/js/project.js |
Added bdr: 8006 to port map; added bdrLandmarksFromAllGenBaseMap() and bdrJunctionsFromAllGenBaseMap() handler functions; extended the main results table cell array from 16 to 28 columns; added populateBDRResults() to write Landmarks/Junctions BDR values into the main table; extended the CSV export with a BDRDetailedOutput.csv file. |
sketchmap_analyser/static/js/sketchmapeditor.js |
Extended runAnalysis() to read the BDR checkboxes and trigger the BDR calculators; added toggleShowMoreBDR()/toggleShowMoreJuncsBDR() and parent/child checkbox listeners. |
sketchmap_analyser/templates/generalizingmaps.html |
Added a "BDR" section with Calculate BDR for Landmarks and Calculate BDR for Junctions checkboxes under the Analyse modal. |
sketchmap_analyser/templates/results.html |
Extended the results table header with grouped Buildings BDR / Junctions BDR column sets (r, DI, phi, theta, alpha1, alpha2 each); moved the "Download Results" button out of the horizontally-scrolling table area. |
sketchmap_analyser/static/css/main.css |
Added hide-landmarks-bdr / hide-junctions-bdr column-visibility rules; fixed a pre-existing hide-buildings bug where the rule targeted table rows instead of columns; made the results table container responsive and horizontally scrollable. |
- Start all services:
docker-compose up --build- Open
http://localhost:8000/generalizingmaps/in your browser. - Load a project and click Analyse -> Both.
- In the Analyse panel, check Calculate BDR for Landmarks and/or Calculate BDR for Junctions, then run Analyse.
- Results will appear in the corresponding Landmarks BDR / Junctions BDR columns of the results table and can be downloaded as part of the CSV export.
⚠️ Note: TheAnalysestep must be run before using the BDR Calculator. The BDR calculation strictly depends on the generalized base maps produced by the initial analysis, just like GMDA.
A massive thankyou to everyone who helped build the BDR Calculator!
- Ajay ajay-sheokand
- Clement Amirault CL-77