nxt-gis
Purpose
nxt-gis is a backend geospatial analysis service that powers infrastructure-planning computations for NXT. It exposes FastAPI endpoints for building-footprint retrieval, pole-placement inference, and distribution-line generation.
Scope
- In scope:
- Geospatial compute endpoints used during grid/site design workflows.
- Building data retrieval from multiple sources (stored Bing data, Google Earth Engine Open Buildings, OSM).
- Pole-coverage and line-layout inference based on geometric/graph algorithms.
- Out of scope:
- Frontend map UX and operator UI workflows.
- Core billing/metering business processes outside planning/geospatial computation.
What this service does in production
- Accepts planning polygons and returns building footprints in GeoJSON.
- Suggests pole locations to cover selected points with configurable coverage algorithms.
- Computes minimum-spanning-tree distribution lines between inferred/selected poles.
- Serves as a backend dependency for planning tools in NXT frontend applications.
Primary workflows
- Building retrieval workflow: call
/buildingswith outline + source + minimum area, receive connected/unconnected building features. - Pole inference workflow: call
/poles-by-coveragewith points + radius + algorithm (GREEDYorKDTREE) to generate candidate pole set. - Line design workflow: call
/distribution-lines-by-poleswith pole FeatureCollection to return MST-based line geometry.
Setup and run
- Repository: github.com/nxtgrid/nxt-gis
- Local run (from source README):
- create/activate virtualenv
pip install -r requirements.txtuvicorn src.app:app --reload
- Production process uses Gunicorn + Uvicorn worker class (
Procfile).
APIs and interfaces
GET /returns service identity/health message.POST /buildingsvalidates request outline area and dispatches to one of three data sources:- stored Bing maps in PostGIS
- Earth Engine Open Buildings
- OpenStreetMap Overpass API
POST /poles-by-coveragecomputes candidate poles using coverage algorithms insrc/services/poles.py.POST /distribution-lines-by-polescomputes MST-based line graph using SciPy distance + sparse graph routines.- Request models and schema constraints are defined in
src/models.py.
Integrations and dependencies
- Datastore: PostgreSQL + PostGIS (geodata source and spatial query path).
- External geodata providers: Google Earth Engine and OpenStreetMap Overpass.
- Python compute stack: FastAPI, Shapely, SciPy, SQLModel/SQLAlchemy, earthengine-api.
- Consumers: planning-oriented NXT frontend tools that need geospatial design outputs in GeoJSON.
Operations notes
- CORS policy is environment-driven (
CORS_ALLOWED_ORIGINSand optional regex). /buildingsenforces max outline area guardrail (MAX_AREA) to bound expensive requests.- Earth Engine is initialized at module load in the buildings service path.
- Key failure modes to diagnose first:
- database connectivity or missing PostGIS extension for stored-building queries,
- Earth Engine credentials misconfiguration for open-buildings source,
- Overpass API errors/timeouts for OSM source.
Source of truth
- Repository: github.com/nxtgrid/nxt-gis
- Service entrypoints and routes:
src/app.py - Request models/validation:
src/models.py - Geospatial service logic:
src/services/buildings.py,src/services/poles.py,src/services/distribution_lines.py - Runtime/deployment process:
Procfile - Environment contract:
.env.example