Format · CityGML
CityGML 2.0 for Rust, Python and JavaScript
Read and write CityGML 2.0 with cadkit in Rust, Python, JavaScript and C: native IDs and references, explicit CRS for new geometry, a local TKGM preflight.
What is supported
| Format | Read | Write | Status |
|---|---|---|---|
| CityGML 2.0 | Readnative XML and geometry | Writenative XML and explicit generic geometry | New geometry needs an explicit CRS. Optional local structural TKGM preflight; not institutional acceptance. |
Supported
- Reading and writing UTF-8 CityGML 2.0 (GML 3.1.1), keeping IDs, references, LoDs, CRS attributes, typed attributes and unknown extension elements
- Buildings, building parts, rooms, installations, openings, boundary surfaces, generic objects and groups
- Structural and geometric validation: rings, planarity, crossings, holes and solids
- Writing drawing geometry as generic city objects with an explicit CRS and level of detail
- An optional local, structural TKGM preflight for two profiles: city-model tender and Digital Building registration
Not supported yet
- CityGML 3.0 and arbitrary GML application schemas
- CRS transformation, axis swapping or guessing a CRS: you name the CRS of the coordinates
- Inferring buildings or rooms from drawing geometry
- External xlinks and referenced polygon rings
- Institutional acceptance: the TKGM preflight is a local check, not an approval
Read CityGML
Read the native model, validate it and project its geometry into the neutral document for SVG, DXF or DGN output.
use cadkit::ReadOptions;use cadkit::gml::{self, ImportOptions};
fn main() -> Result<(), cadkit::Error> { let native = gml::read_native(&std::fs::read("building.gml")?, &ReadOptions::default())?; let doc = gml::to_document(&native, &ImportOptions::new(), &ReadOptions::default())?; println!("{} entities", doc.entity_count()); // neutral geometry view Ok(())}import cadkit
with open("building.gml", "rb") as f: native = cadkit.read_citygml(f.read()) # keeps IDs, references, attributesprint(native.validate())doc = native.to_document() # neutral geometry view, e.g. for SVG or DXFprint(doc)import { readFileSync } from "node:fs";import { readCityGml } from "cadkit-wasm/node";
const native = readCityGml(readFileSync("building.gml")); // keeps IDs, references, attributesconsole.log(native.validate());native.free();#include <stdio.h>#include "cadkit.h"
int main(void) { cadkit_document *doc = NULL; /* neutral geometry view of the CityGML file */ if (cadkit_read_file("building.gml", NULL, &doc) != CADKIT_OK) return 1; cadkit_info info; if (cadkit_document_info(doc, &info) == CADKIT_OK) printf("%llu entities\n", (unsigned long long)info.entity_count); cadkit_document_free(doc); return 0;}Write, validate and preflight from the shell
New geometry needs --crs. The preflight reports what a TKGM delivery would still need; see CityGML 2.0 and the TKGM preflight.
cadkit convert surfaces.dxf model.gml --crs urn:ogc:def:crs:EPSG::32635 --lod 1cadkit validate-gml model.gml > validation.jsoncadkit validate-gml model.gml --tkgm-profile city-model-tender > preflight.json \ || echo "preflight reported issues; see preflight.json"