Skip to content
cadkithome
Menu

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

FormatReadWriteStatus
CityGML 2.0Readnative XML and geometryWritenative XML and explicit generic geometryNew 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.

src/main.rs
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(())
}

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.

shell
cadkit convert surfaces.dxf model.gml --crs urn:ogc:def:crs:EPSG::32635 --lod 1
cadkit validate-gml model.gml > validation.json
cadkit validate-gml model.gml --tkgm-profile city-model-tender > preflight.json \
|| echo "preflight reported issues; see preflight.json"

Reference