feat(parcel-sync): import eTerra immovables without geometry

- Add geometrySource field to GisFeature (NO_GEOMETRY marker)
- New no-geom-sync service: scan + import parcels missing from GIS layer
- Uses negative immovablePk as objectId to avoid @@unique collision
- New /api/eterra/no-geom-scan endpoint for counting
- Export-bundle: includeNoGeometry flag, imports before enrich
- CSV export: new HAS_GEOMETRY column (0/1)
- GPKG: still geometry-only (unchanged)
- UI: checkbox + scan button on Export tab
- Baza de Date tab: shows no-geometry counts per UAT
- db-summary API: includes noGeomCount per layer
This commit is contained in:
AI Assistant
2026-03-07 12:58:10 +02:00
parent d50b9ea0e2
commit 30915e8628
6 changed files with 604 additions and 22 deletions
+18 -16
View File
@@ -22,24 +22,25 @@ model KeyValueStore {
// ─── GIS: eTerra ParcelSync ────────────────────────────────────────
model GisFeature {
id String @id @default(uuid())
layerId String // e.g. TERENURI_ACTIVE, CLADIRI_ACTIVE
siruta String
objectId Int // eTerra OBJECTID (unique per layer)
inspireId String?
cadastralRef String? // NATIONAL_CADASTRAL_REFERENCE
areaValue Float?
isActive Boolean @default(true)
attributes Json // all raw eTerra attributes
geometry Json? // GeoJSON geometry (Polygon/MultiPolygon)
id String @id @default(uuid())
layerId String // e.g. TERENURI_ACTIVE, CLADIRI_ACTIVE
siruta String
objectId Int // eTerra OBJECTID (unique per layer); negative for no-geometry parcels (= -immovablePk)
inspireId String?
cadastralRef String? // NATIONAL_CADASTRAL_REFERENCE
areaValue Float?
isActive Boolean @default(true)
attributes Json // all raw eTerra attributes
geometry Json? // GeoJSON geometry (Polygon/MultiPolygon)
geometrySource String? // null = normal GIS sync, "NO_GEOMETRY" = eTerra immovable without GIS geometry
// NOTE: native PostGIS column 'geom' is managed via SQL trigger (see prisma/postgis-setup.sql)
// Prisma doesn't need to know about it — trigger auto-populates from geometry JSON
enrichment Json? // magic data: CF, owners, address, categories, etc.
enrichedAt DateTime? // when enrichment was last fetched
syncRunId String?
projectId String? // link to project tag
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
enrichment Json? // magic data: CF, owners, address, categories, etc.
enrichedAt DateTime? // when enrichment was last fetched
syncRunId String?
projectId String? // link to project tag
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
syncRun GisSyncRun? @relation(fields: [syncRunId], references: [id])
@@ -48,6 +49,7 @@ model GisFeature {
@@index([cadastralRef])
@@index([layerId, siruta])
@@index([projectId])
@@index([geometrySource])
}
model GisSyncRun {