Geometry Handling
Overview
Section titled “Overview”Formation uses WKT (Well-Known Text) for geometry storage via NetTopologySuite in the backend and GeoJSON for map rendering in the frontend.
Backend
Section titled “Backend”Geometry is stored as SQL Server geometry types and exposed via the API as WKT strings:
// Entity modelpublic Point? DbLocation { get; set; } // POINT(-0.1234 51.5678)
// API exposure[NotMapped]public string? Location { get; set; } // "POINT(-0.1234 51.5678)"Frontend
Section titled “Frontend”The frontend converts between WKT and GeoJSON for map rendering:
import { wktToGeoJSON, geojsonToWKT } from '@terraformer/wkt'
// Display on mapconst geoJson = wktToGeoJSON('POINT(-0.1234 51.5678)')
// Send back to APIconst wkt = geojsonToWKT(geoJson)Invalid Geometry Handling
Section titled “Invalid Geometry Handling”The GeometryValidationService filters entities with corrupt geometries before returning them from the API. Invalid geometries have their Location or Boundary set to null, with a warning logged.
// Called automatically in controllers_geometryValidationService.FilterInvalidGeometries(results);This prevents “shell is empty” errors when rendering invalid geometries on the frontend.