diff --git a/crates/data/src/citygml.rs b/crates/data/src/citygml.rs index c7ac766406..7de3104747 100644 --- a/crates/data/src/citygml.rs +++ b/crates/data/src/citygml.rs @@ -1,4 +1,4 @@ -//! CityGML 1.0 and 2.0 (OGC 08-007r1 and 12-019), read as 2D like every city model: each city +//! CityGML 1.0, 2.0 and 3.0 (OGC 08-007r1, 12-019 and 21-006), read as 2D like every city model: each city //! object becomes a row of a layer per object type and geometry family, its surfaces and solids a //! footprint with its heights in `z_min`, `z_max` and `height` (see [`crate::citymodel`]). Written //! from the standards and their XML schemas. @@ -14,6 +14,13 @@ //! latitude first, as GML 3 says. Names that disagree are refused, unless a system is given in //! their place, which reads them all and says how many named another. //! +//! 3.0 is read by the same names where they stay (its geometry properties, `cityObjectMember`), and +//! by its own where they change: thematic surfaces in `boundary`, openings in `fillingSurface`, a +//! prototype in `relativeGeometry`, parts linked by `buildingPart` (and a bridge's or tunnel's), +//! generic attributes named by a `gen:name`, and a group member inside its `Role`. Its spaces (a +//! `BuildingRoom`, a `Storey`) are objects like any other. Those names are read only in 3.0's +//! namespaces ([`in_3_0`]): an extension of a 1.0 or 2.0 model that uses one keeps its own meaning. +//! //! Attributes: generic attributes (`gen:stringAttribute` and its kin) typed by their element, the //! measures and counts the standard types so (`measuredHeight`, `storeysAboveGround`, …) and any //! property with a unit (`uom`) in metres as numbers, a measure in another unit than the metre as @@ -38,13 +45,13 @@ //! links read is bounded by the member's size, and what links copy and read from other members by //! the file's. A geometry that can't be read is said once, whichever object or link reads it first. //! -//! An implicit geometry (`ImplicitGeometry`) is its prototype (`relativeGMLGeometry`, written in +//! An implicit geometry (`ImplicitGeometry`) is its prototype ([`PROTOTYPES`], written in //! place or given by a link), placed by its matrix at its reference point (OGC 12-019 §8.3), in the //! file's axis order: the prototype is read once, in its own system, and placed for each instance, //! the points placed in all as many as the file could write out. //! //! A part, a group's member or a group's parent given by a link (`consistsOfBuildingPart`, -//! `groupMember`, a `CityObjectGroup`'s `parent`) makes the objects it names a child and its parent, +//! `buildingPart`, `bridgePart`, `tunnelPart`, `groupMember`, a `CityObjectGroup`'s `parent`) makes the objects it names a child and its parent, //! as if one were written in the other, once every member is read; the link is kept as an attribute //! too. //! @@ -56,7 +63,8 @@ //! geometry whose prototype is in another file (`libraryObject`) or whose matrix isn't 16 numbers //! with `0 0 0 1` last (drawn at its reference point); a group member's role; appearances, //! addresses, TIN reliefs, and the properties of thematic surfaces and openings (a name, generic -//! attributes); curve arcs and splines are read as straight lines. CityGML 3.0 is refused. +//! attributes); 3.0's relations between objects (`CityObjectRelation`) and its versions +//! (`versionMember`, `versionTransitionMember`); curve arcs and splines are read as straight lines. use std::borrow::Cow; use std::collections::{HashMap, HashSet, hash_map::Entry}; @@ -90,13 +98,55 @@ const LINK_READS: usize = 4; /// The namespace every CityGML version's core namespace starts with. const CITYGML: &str = "http://www.opengis.net/citygml/"; +/// CityGML 3.0's core namespace. +const CITYGML_3: &str = "http://www.opengis.net/citygml/3.0"; + /// The CityGML versions read, by their core namespace. -const VERSIONS: [&str; 2] = ["http://www.opengis.net/citygml/1.0", "http://www.opengis.net/citygml/2.0"]; +const VERSIONS: [&str; 3] = ["http://www.opengis.net/citygml/1.0", "http://www.opengis.net/citygml/2.0", CITYGML_3]; /// The properties whose features are surfaces of their object (thematic surfaces, openings, traffic /// areas), not objects of their own. const SURFACE_PROPERTIES: [&str; 4] = ["boundedBy", "opening", "trafficArea", "auxiliaryTrafficArea"]; +/// 3.0's names for them, read only in its namespaces ([`in_3_0`]): a thematic surface's +/// `boundary`, an opening's `fillingSurface`. +const SURFACE_PROPERTIES_3: [&str; 2] = ["boundary", "fillingSurface"]; + +/// The property holding an implicit geometry's prototype: `relativeGMLGeometry` in 1.0 and 2.0, +/// `relativeGeometry` in 3.0 (read only there, see [`in_3_0`]). +const PROTOTYPES: [&str; 2] = ["relativeGMLGeometry", "relativeGeometry"]; + +/// 3.0's properties linking a part to its object, which 1.0 and 2.0 call `consistsOf…` (read only +/// in its namespaces, see [`in_3_0`]). +const PARTS: [&str; 3] = ["buildingPart", "bridgePart", "tunnelPart"]; + +/// Whether an element is in one of CityGML 3.0's namespaces. The names 3.0 adds (`boundary`, +/// `fillingSurface`, `relativeGeometry`, `buildingPart`, `genericAttribute`, `relatedTo`, a group +/// member's `Role`) are read only there: an extension (ADE) of a 1.0 or 2.0 model may give one of +/// them to a property of its own, which keeps the meaning it had. +fn in_3_0(n: &Node) -> bool { + n.tag_name().namespace().is_some_and(|ns| ns.starts_with(CITYGML) && ns.ends_with("/3.0")) +} + +/// Whether a property's features are surfaces of its object ([`SURFACE_PROPERTIES`], +/// [`SURFACE_PROPERTIES_3`]). +fn surface_property(p: &Node) -> bool { + let name = local(p); + SURFACE_PROPERTIES.contains(&name) || (SURFACE_PROPERTIES_3.contains(&name) && in_3_0(p)) +} + +/// Whether a property holds an implicit geometry's prototype ([`PROTOTYPES`]), by its name and, in +/// the index, which doesn't resolve namespaces, whether the model is 3.0 (`three`). +fn prototype_name(name: &str, three: bool) -> bool { + let [old, new] = PROTOTYPES; + name == old || (three && name == new) +} + +/// Whether an element holds an implicit geometry's prototype ([`PROTOTYPES`]). +fn prototype_property(n: &Node) -> bool { + prototype_name(local(n), in_3_0(n)) +} + /// Features written in UpperCamelCase that are a property's value, not a city object. const VALUES: [&str; 4] = ["Envelope", "Null", "Address", "Appearance"]; @@ -131,7 +181,7 @@ const GEOMETRIES: [&str; 22] = [ const COUNTS: [&str; 4] = ["storeysAboveGround", "storeysBelowGround", "yearOfConstruction", "yearOfDemolition"]; /// Whether a file is a CityGML city model, by its root: a `CityModel` in one of CityGML's -/// namespaces (3.0's too, which [`read`] refuses by name). Other GML, a WFS answer that only +/// namespaces. Other GML, a WFS answer that only /// mentions CityGML's namespaces, isn't. pub fn looks_like_citygml(bytes: &[u8]) -> bool { let head = String::from_utf8_lossy(bytes.get(..HEAD_BYTES).unwrap_or(bytes)); @@ -192,6 +242,7 @@ fn read_with(file_name: &str, bytes: &[u8], given: Option, keep_named: bool let (link_bytes, placing) = (text.len().saturating_mul(LINK_READS), text.len() / POINT_BYTES); let mut reading = Reading { budget: MAX_FILE_FACES, swap, link_bytes, placing, ..Reading::default() }; reading.said.appearances = index.appearances; + reading.said.versions = index.versions; reading.said.links = index.links; reading.said.repeated_geometry_ids = index.repeated; let (mut wrapped, mut far) = (String::new(), Vec::new()); @@ -324,6 +375,10 @@ struct Index { other: Option, /// The appearances the model holds, which aren't read. appearances: usize, + /// The versions the model holds (3.0), which aren't read. + versions: usize, + /// Whether the model is CityGML 3.0, whose own names the index reads only then. + three: bool, /// Members given only by a link that the index alone meets (an empty `featureMembers`), which /// aren't followed. links: usize, @@ -362,7 +417,7 @@ struct Spot { enum Kind { /// A geometry a link reads where it stands. Geometry, - /// A geometry in an implicit geometry's prototype (`relativeGMLGeometry`), read only placed. + /// A geometry in an implicit geometry's prototype ([`PROTOTYPES`]), read only placed. Prototype, /// Anything else: an object, a surface, a ring, or a geometry where this reader draws nothing. Other, @@ -552,7 +607,13 @@ fn linkable_name(name: &str) -> bool { /// Whether an element holds what this reader doesn't draw: an appearance, a terrain intersection /// curve, a TIN relief. A link to a geometry in one isn't followed. fn undrawn(name: &str) -> bool { - matches!(name, "appearance" | "appearanceMember" | "Appearance" | "TINRelief") || name.ends_with("TerrainIntersection") + matches!(name, "appearance" | "appearanceMember" | "Appearance" | "TINRelief") || terrain_intersection(name) +} + +/// Whether a property is a terrain intersection, where an object meets the ground: an auxiliary +/// line, not the object's shape (`lod2TerrainIntersection`, `lod2TerrainIntersectionCurve` in 3.0). +fn terrain_intersection(name: &str) -> bool { + name.ends_with("TerrainIntersection") || name.ends_with("TerrainIntersectionCurve") } impl Index { @@ -613,13 +674,13 @@ impl Index { scope: if own { scopes.stack.len() - 1 } else { around }, own, dim: written_dim(e).or(dim), - prototype: prototype || name == "relativeGMLGeometry", + prototype: prototype || prototype_name(name, self.three), undrawn: hidden || undrawn(name), }); } - /// Indexes a document in one pass, building no tree. Refuses one whose root isn't a CityGML 1.0 - /// or 2.0 city model, and, unless `overridden` (a system is given in their place), one whose + /// Indexes a document in one pass, building no tree. Refuses one whose root isn't a CityGML 1.0, + /// 2.0 or 3.0 city model, and, unless `overridden` (a system is given in their place), one whose /// `srsName`s name different systems; `archive` for a member of one. fn of(file_name: &str, text: &str, overridden: bool, archive: bool) -> Result { let invalid = |e: quick_xml::Error| DataError::Format(format!("{file_name}: {e}")); @@ -634,7 +695,7 @@ impl Index { // `featureMembers`'s), and the elements open in a member. let mut scopes = Scopes { stack: Vec::new(), left: text.len() }; let (mut base, mut open) = (0, Vec::::new()); - // The depth of the prototype being read (`relativeGMLGeometry`): its system is its own, not + // The depth of the prototype being read ([`PROTOTYPES`]): its system is its own, not // the file's. let mut prototype: Option = None; // Open elements, and whether the root has been seen. @@ -701,6 +762,7 @@ impl Index { } rooted = true; check_root(file_name, e)?; + index.three = root_namespace(e).as_deref().map(str::trim) == Some(CITYGML_3); index.namespaces = declarations(e); let gml = gml_prefixes(e); let bytes = gml.iter().map(String::len).sum(); @@ -711,7 +773,7 @@ impl Index { { index.see_system(file_name, srs.trim())?; } - if prototype.is_none() && !empty && e.local_name().into_inner() == "relativeGMLGeometry" { + if prototype.is_none() && !empty && prototype_name(e.local_name().into_inner(), index.three) { prototype = Some(depth); } match (depth, holder) { @@ -735,6 +797,7 @@ impl Index { } } "appearanceMember" => index.appearances += 1, + "versionMember" | "versionTransitionMember" => index.versions += 1, _ => {} }, // An object of a `featureMembers`. @@ -814,17 +877,14 @@ impl Index { } } -/// Refuses a root that isn't a CityGML 1.0 or 2.0 city model. +/// Refuses a root that isn't a CityGML 1.0, 2.0 or 3.0 city model. fn check_root(file_name: &str, e: &BytesStart) -> Result<()> { if e.local_name().into_inner() != "CityModel" { return Err(DataError::Format(format!("{file_name}: not a CityGML city model (its root isn't CityModel)"))); } match root_namespace(e).as_deref().map(str::trim) { Some(ns) if VERSIONS.contains(&ns) => Ok(()), - Some("http://www.opengis.net/citygml/3.0") => { - Err(DataError::Unsupported(format!("{file_name}: CityGML 3.0: RustGIS reads CityGML 1.0 and 2.0"))) - } - _ => Err(DataError::Format(format!("{file_name}: not a CityGML 1.0 or 2.0 city model (its root's namespace isn't one)"))), + _ => Err(DataError::Format(format!("{file_name}: not a CityGML 1.0, 2.0 or 3.0 city model (its root's namespace isn't one)"))), } } @@ -912,7 +972,7 @@ fn undrawn_at(n: &Node) -> bool { /// Whether an element is in an implicit geometry's prototype, in its own system: only its implicit /// geometries place it. fn in_prototype(n: &Node) -> bool { - n.ancestors().skip(1).any(|a| local(&a) == "relativeGMLGeometry") + n.ancestors().skip(1).any(|a| prototype_property(&a)) } /// Whether a line or ring holds a point or curve given only by a link, so it isn't whole. @@ -945,10 +1005,10 @@ fn is_object(e: &Node) -> bool { || local(e) == "TINRelief" || elements(*e).any(|p| { // A terrain intersection is an auxiliary line, not the feature's geometry. - !local(&p).ends_with("TerrainIntersection") + !terrain_intersection(local(&p)) && (property_lod(&p).is_some() || elements(p).next().is_some_and(|g| is_geometry(&g)) - || (SURFACE_PROPERTIES.contains(&local(&p)) && elements(p).any(|s| !is_gml(&s))) + || (surface_property(&p) && elements(p).any(|s| !is_gml(&s))) // A wrapper with no id of its own, which carries the objects it holds. || elements(p).any(|c| is_object(&c))) })) @@ -982,11 +1042,15 @@ fn measure(text: &str, uom: Option<&str>) -> Option { /// `gen:measureAttribute` with its unit; the others are text), and a set's as an object of its /// attributes. fn generic_value(a: &Node) -> Json { - if local(a) == "genericAttributeSet" { + // 3.0 names them with a capital (`gen:IntAttribute`), and wraps each of a set's in a + // `genericAttribute`. + let kind = local(a); + if kind.eq_ignore_ascii_case("genericAttributeSet") { let mut set = Map::new(); for member in elements(*a) { - if let Some(name) = attribute(&member, "name") { - insert(&mut set, name, generic_value(&member)); + let member = if local(&member) == "genericAttribute" { elements(member).next() } else { Some(member) }; + if let Some((member, name)) = member.and_then(|m| generic_name(&m).map(|n| (m, n))) { + insert(&mut set, &name, generic_value(&member)); } } return Json::Object(set); @@ -994,15 +1058,38 @@ fn generic_value(a: &Node) -> Json { let value = elements(*a).find(|v| local(v) == "value"); let text = value.as_ref().map(text).unwrap_or_default(); let text = text.trim(); - let number = match local(a) { - "intAttribute" => text.parse::().ok().map(Json::from), - "doubleAttribute" => measure(text, None), - "measureAttribute" => measure(text, value.as_ref().and_then(|v| attribute(v, "uom")).or_else(|| attribute(a, "uom"))), - _ => None, + let number = if kind.eq_ignore_ascii_case("intAttribute") { + text.parse::().ok().map(Json::from) + } else if kind.eq_ignore_ascii_case("doubleAttribute") { + measure(text, None) + } else if kind.eq_ignore_ascii_case("measureAttribute") { + measure(text, value.as_ref().and_then(|v| attribute(v, "uom")).or_else(|| attribute(a, "uom"))) + } else { + None }; number.unwrap_or_else(|| Json::from(text)) } +/// A generic attribute's name: an attribute of it in 1.0 and 2.0 (kept as written), its `gen:name` +/// in 3.0 (none when blank). +fn generic_name(a: &Node) -> Option { + if let Some(name) = attribute(a, "name") { + return Some(name.to_string()); + } + elements(*a).find(|n| local(n) == "name").map(|n| text(&n).trim().to_string()).filter(|n| !n.is_empty()) +} + +/// 3.0's group member: a `groupMember` holding a `Role`, which holds the member (a `groupMember`) +/// and its role (`role`). Gives the member, and whether the role is given. +fn group_role<'a, 'i>(p: &Node<'a, 'i>) -> Option<(bool, Node<'a, 'i>)> { + if local(p) != "groupMember" || !in_3_0(p) { + return None; + } + let role = elements(*p).next().filter(|r| local(r) == "Role")?; + let member = elements(role).find(|m| local(m) == "groupMember")?; + Some((elements(role).any(|r| local(&r) == "role" && !text(&r).trim().is_empty()), member)) +} + /// Whether a unit of measure is the metre. fn is_metre(uom: &str) -> bool { let u = uom.trim().to_ascii_lowercase(); @@ -1063,11 +1150,15 @@ struct Said { repeated_ids: usize, /// Geometries whose `gml:id`, which a link names, an earlier element of a member has too. repeated_geometry_ids: usize, - /// Links that would make one object another's part (`consistsOfBuildingPart`, `groupMember`, a - /// group's `parent`) naming no other object of the file, or made by an object with no id. + /// Links that would make one object another's part (`consistsOfBuildingPart`, 3.0's + /// `buildingPart`, `bridgePart` and `tunnelPart`, `groupMember`, a group's `parent`) naming no other object of the file, or made by an object with no id. object_links: usize, /// Group members with a role in their group (`role`), which isn't kept. group_roles: usize, + /// 3.0's relations between city objects (`relatedTo`, a `CityObjectRelation`), not read. + object_relations: usize, + /// 3.0's versions of the model (`versionMember`, `versionTransitionMember`), not read. + versions: usize, terrain_intersections: usize, appearances: usize, /// Curves with arcs or splines, read as straight lines through their points. @@ -1078,6 +1169,8 @@ struct Said { not_objects: usize, /// Values naming the code list they are taken from (`codeSpace`), which isn't kept. code_spaces: usize, + /// Sets of generic attributes naming a code list (`codeSpace`), which isn't kept. + set_code_spaces: usize, /// Values with attributes other than their unit and code list (a language, `xml:lang`), which /// aren't kept. value_attributes: usize, @@ -1159,11 +1252,19 @@ impl Said { say( self.object_links, format!( - "{} links between city objects (consistsOfBuildingPart, groupMember, a group's parent) name no other city object of the file, or are made by one with no gml:id: the link is kept as an attribute, but no parent is", + "{} links between city objects (consistsOfBuildingPart, buildingPart, bridgePart, tunnelPart, groupMember, a group's parent) name no other city object of the file, or are made by one with no gml:id: the link is kept as an attribute, but no parent is", self.object_links ), ); say(self.group_roles, format!("{} members of groups (groupMember) have a role in their group, which isn't kept", self.group_roles)); + say( + self.object_relations, + format!("{} relations between city objects (CityObjectRelation) aren't read and are left out", self.object_relations), + ); + say( + self.versions, + format!("the file's versions (versionMember, versionTransitionMember) aren't read: {} are left out", self.versions), + ); say( self.terrain_intersections, format!( @@ -1191,6 +1292,13 @@ impl Said { self.code_spaces ), ); + say( + self.set_code_spaces, + format!( + "{} sets of generic attributes (genericAttributeSet) name a code list (codeSpace), which isn't kept", + self.set_code_spaces + ), + ); say( self.value_attributes, format!( @@ -1200,7 +1308,10 @@ impl Said { ); say( self.unnamed_generic, - format!("{} generic attributes in a set (genericAttributeSet) have no name, and are left out", self.unnamed_generic), + format!( + "{} generic attributes (genericAttribute, or a member of a genericAttributeSet) have no name, and are left out", + self.unnamed_generic + ), ); say( self.not_features, @@ -1606,16 +1717,22 @@ impl Reading { /// set's members with no name. fn said_generic(&mut self, a: &Node) { for v in a.descendants().filter(|n| n.is_element() && local(n) == "value") { - let measure = v.parent_element().is_some_and(|p| local(&p) == "measureAttribute"); + let measure = v.parent_element().is_some_and(|p| local(&p).eq_ignore_ascii_case("measureAttribute")); self.said.code_spaces += usize::from(attribute(&v, "codeSpace").is_some()); self.said.value_attributes += usize::from(v.attributes().any(|at| !(at.name() == "codeSpace" || (measure && at.name() == "uom")))); } - self.said.unnamed_generic += a - .descendants() - .filter(|n| n.is_element() && n.parent_element().is_some_and(|p| local(&p) == "genericAttributeSet")) - .filter(|n| attribute(n, "name").is_none()) - .count(); + // A set's members with no name, and the code list a set names: 2.0 names a member by its + // `name` and a set's list by its `codeSpace`, attributes; 3.0 by `gen:name` and + // `gen:codeSpace` children, each member in a `genericAttribute`. + for set in a.descendants().filter(|n| n.is_element() && local(n).eq_ignore_ascii_case("genericAttributeSet")) { + self.said.set_code_spaces += + usize::from(attribute(&set, "codeSpace").is_some() || elements(set).any(|c| local(&c) == "codeSpace")); + for member in elements(set).filter(|m| !matches!(local(m), "name" | "codeSpace")) { + let member = if local(&member) == "genericAttribute" { elements(member).next() } else { Some(member) }; + self.said.unnamed_generic += usize::from(member.is_none_or(|m| generic_name(&m).is_none())); + } + } } /// Reads a city object into its rows, then the objects nested in it. Its links are followed @@ -1638,16 +1755,36 @@ impl Reading { let mut heads = Vec::new(); let mut address = false; for p in elements(e) { + // A group member's role in its group isn't kept; 3.0 writes the member inside it. + let p = match group_role(&p) { + Some((role, member)) => { + self.said.group_roles += usize::from(role); + member + } + None => p, + }; let name = local(&p); let first = elements(p).next(); - // A group member's role in its group isn't kept. self.said.group_roles += usize::from(name == "groupMember" && attribute(&p, "role").is_some()); if (name.ends_with("Attribute") || name == "genericAttributeSet") && let Some(key) = attribute(&p, "name") { self.said_generic(&p); insert(&mut attributes, key, generic_value(&p)); - } else if name.ends_with("TerrainIntersection") { + } else if name == "genericAttribute" && in_3_0(&p) { + // 3.0's: the attribute inside, named by its `gen:name`. + for a in elements(p) { + match generic_name(&a) { + Some(key) => { + self.said_generic(&a); + insert(&mut attributes, &key, generic_value(&a)); + } + None => self.said.unnamed_generic += 1, + } + } + } else if name == "relatedTo" && in_3_0(&p) && first.is_some_and(|f| local(&f) == "CityObjectRelation") { + self.said.object_relations += 1; + } else if terrain_intersection(name) { // Where the object meets the ground: an auxiliary line, not the object's shape. self.said.terrain_intersections += 1; } else if let Some(rank) = property_lod(&p) { @@ -1656,7 +1793,7 @@ impl Reading { address = true; } else if name == "appearance" { self.said.appearances += 1; - } else if only_link(&p) && SURFACE_PROPERTIES.contains(&name) { + } else if only_link(&p) && surface_property(&p) { self.said.links += 1; } else if let Some(href) = attribute(&p, "href").filter(|_| first.is_none()) { // A relation to another feature (a group's members, a generalization), kept as @@ -1664,7 +1801,9 @@ impl Reading { // link a child and its parent, as if written one in the other. let other = fragment(href); let relation = match name { - _ if name.starts_with("consistsOf") || name == "groupMember" => Some((other, id)), + _ if name.starts_with("consistsOf") || (PARTS.contains(&name) && in_3_0(&p)) || name == "groupMember" => { + Some((other, id)) + } "parent" if ty == "CityObjectGroup" => Some((id, other)), _ => None, }; @@ -1681,7 +1820,7 @@ impl Reading { } else if first.is_some_and(|f| is_gml(&f)) { // A geometry in a property that names no level of detail (a group's, a relief's). self.geometry(&p, At { lod: None, ground: false }, &mut parts, &mut links); - } else if first.is_some_and(|f| SURFACE_PROPERTIES.contains(&name) && local(&f).starts_with(char::is_uppercase)) { + } else if first.is_some_and(|f| surface_property(&p) && local(&f).starts_with(char::is_uppercase)) { elements(p).for_each(|s| self.surface(&s, &mut parts, &mut links)); } else if elements(p).any(|c| is_object(&c)) { // The objects; a feature beside them with no id and no geometry is said. A group's @@ -1969,7 +2108,7 @@ impl Reading { for p in elements(*s) { if let Some(rank) = property_lod(&p) { self.geometry(&p, At { lod: Some(rank), ground }, parts, links); - } else if local(&p) == "opening" { + } else if local(&p) == "opening" || (local(&p) == "fillingSurface" && in_3_0(&p)) { if only_link(&p) { self.said.links += 1; } else { @@ -2414,7 +2553,7 @@ impl<'a, 'i> Walk<'_, 'a, 'i> { Some(()) } - /// An implicit geometry: its prototype (`relativeGMLGeometry`), written in place or given by a + /// An implicit geometry: its prototype ([`PROTOTYPES`]), written in place or given by a /// link, placed by its matrix at its reference point once its object's own geometries are read. /// One whose prototype is in another file (`libraryObject`), or whose matrix isn't 16 numbers /// with `0 0 0 1` last, is its reference point, with no height. @@ -2443,7 +2582,7 @@ impl<'a, 'i> Walk<'_, 'a, 'i> { } Placement::new(&v, reference) }); - let shape = elements(*g).find(|c| local(c) == "relativeGMLGeometry"); + let shape = elements(*g).find(prototype_property); let to = match shape { Some(rel) if only_link(&rel) => attribute(&rel, "href").map(To::Href), Some(rel) => elements(rel).next().map(To::Node), diff --git a/crates/data/src/citygml/tests.rs b/crates/data/src/citygml/tests.rs index aec9fa2714..46e30bdd97 100644 --- a/crates/data/src/citygml/tests.rs +++ b/crates/data/src/citygml/tests.rs @@ -94,10 +94,11 @@ fn layer<'a>(out: &'a [(Dataset, ReadReport)], name: &str) -> &'a Dataset { fn it_is_known_by_its_root_and_namespace() { assert!(looks_like_citygml(&lonlat(""))); assert!(!looks_like_citygml(br#""#)); - let three = br#""#; - assert!(looks_like_citygml(three), "3.0 is known, to be refused by name"); - let err = read("new.gml", three, None).unwrap_err().to_string(); - assert!(err.contains("CityGML 3.0: RustGIS reads CityGML 1.0 and 2.0"), "{err}"); + assert!(looks_like_citygml(&model3("EPSG:4326", "")), "3.0's too"); + let err = read("next.gml", br#""#, None) + .unwrap_err() + .to_string(); + assert!(err.contains("not a CityGML 1.0, 2.0 or 3.0 city model"), "{err}"); let err = read("a.gml", br#""#, None).unwrap_err().to_string(); assert!(err.contains("its root isn't CityModel"), "{err}"); let err = read("a.gml", &lonlat(""), None).unwrap_err().to_string(); @@ -1437,7 +1438,11 @@ fn generic_value_attributes_that_are_not_kept_are_said() { let out = read("model.gml", &lonlat(&building("b1", &inner)), None).unwrap(); assert!(says(&out, "1 values have attributes other than their unit (uom) or code list (codeSpace)"), "{:?}", messages_of(&out)); assert!(says(&out, "1 values name the code list they are taken from (codeSpace)"), "{:?}", messages_of(&out)); - assert!(says(&out, "1 generic attributes in a set (genericAttributeSet) have no name"), "{:?}", messages_of(&out)); + assert!( + says(&out, "1 generic attributes (genericAttribute, or a member of a genericAttributeSet) have no name"), + "{:?}", + messages_of(&out) + ); let clean = format!( r#"Town hall 2{}"#, @@ -2333,3 +2338,187 @@ fn a_curved_mesh_is_merged_in_a_moment() { assert!(out[0].0.features[0].geometry.is_some()); assert!(!says(&out, "outline"), "merged, not drawn as the outline of its points: {:?}", messages_of(&out)); } + +/// A CityGML 3.0 city model in `srs`, its core the default namespace as 3.0's own samples write +/// it, holding `members`. +fn model3(srs: &str, members: &str) -> Vec { + format!( + r#" + + + 0 0 010 10 5 + + {members} +"# + ) + .into_bytes() +} + +/// 2.0 members written as 3.0 writes them: members and implicit geometries in core, which is the +/// default namespace; thematic surfaces in `boundary` from the construction module; geometry +/// properties in core; openings in `fillingSurface`; parts in `buildingPart`; a prototype in +/// `relativeGeometry`. +fn three(members: &str) -> String { + let mut s = members + .replace("core:cityObjectMember", "cityObjectMember") + .replace("bldg:boundedBy", "boundary") + .replace("bldg:consistsOfBuildingPart", "bldg:buildingPart") + .replace("bldg:opening", "con:fillingSurface") + .replace("bldg:Door", "con:DoorSurface") + .replace("core:relativeGMLGeometry", "relativeGeometry") + .replace("frn:lod2ImplicitRepresentation", "lod2ImplicitRepresentation"); + for name in ["ImplicitGeometry", "referencePoint", "transformationMatrix"] { + s = s.replace(&format!("core:{name}"), name); + } + for kind in ["GroundSurface", "WallSurface", "RoofSurface"] { + s = s.replace(&format!("bldg:{kind}"), &format!("con:{kind}")); + } + for lod in 0..4 { + for g in ["MultiSurface", "Solid", "MultiCurve"] { + s = s.replace(&format!("bldg:lod{lod}{g}"), &format!("lod{lod}{g}")); + } + } + s +} + +/// The same model written in 3.0 reads as in 2.0: the same layers, rows, footprints, heights and +/// notices, for thematic surfaces, an opening, a part, a solid linking its surfaces' polygons, and implicit +/// geometries placed in place and linked from another member. +#[test] +fn a_3_0_model_reads_as_the_same_model_in_2_0() { + let solid = r##" + + "##; + let part = format!( + r#"{}"#, + box_surfaces("p1") + ); + let door = format!( + r#"{}"#, + polygon("d1-f", "2 0 0 4 0 0 4 0 2 2 0 2 2 0 0") + ); + let prototype = format!( + r#"{}"#, + polygon("proto-f", &square(0.0, 0.0, 1.0, 0.0)) + ); + let members = [ + building("b1", &format!("{}{door}{solid}{part}", box_surfaces("b1"))), + furniture( + "t1", + &format!( + "2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1{prototype}{}", + reference(5.0, 5.0, 1.0) + ), + ), + furniture("t2", &format!(r##"{}"##, reference(20.0, 20.0, 0.0))), + ] + .concat(); + let two = read("model.gml", &lonlat(&members), None).unwrap(); + let three = read("model.gml", &model3("EPSG:4326", &three(&members)), None).unwrap(); + assert!( + two.len() > 1 && layer(&two, "model BuildingPart").features.len() == 1, + "{:?}", + two.iter().map(|(d, _)| &d.name).collect::>() + ); + assert!(!says(&two, "thematic surfaces or openings"), "the door is an opening: {:?}", messages_of(&two)); + assert_eq!(format!("{three:?}"), format!("{two:?}")); +} + +/// 3.0's own ways: a part, a group's member and its role given by links, generic attributes named +/// by `gen:name` (a set's too), and its spaces as objects; what it holds that isn't read (relations +/// between objects, versions, terrain intersection curves, generic attributes with no name, a +/// set's code list) is said, and a clean 3.0 model says none of it. +#[test] +fn a_3_0_model_reads_its_own_ways_and_says_what_it_leaves_out() { + let building = format!( + r##" + rooms12 + code007 + survey + area10.5 + + + {} + {}"##, + three(&surface("FloorSurface", &[polygon("room1-f", &square(1.0, 1.0, 2.0, 0.0))])) + .replace("bldg:FloorSurface", "con:FloorSurface"), + three(&box_surfaces("b1")) + ); + let part = format!( + r#"{}"#, + three(&box_surfaces("p1")) + ); + let group = r##" + landmark + + "##; + let clean = read("model.gml", &model3("EPSG:4326", &[building.as_str(), &part, group].concat()), None).unwrap(); + let ds = layer(&clean, "model Building"); + assert_eq!(value(ds, 0, "rooms"), Value::Int(12)); + assert_eq!(value(ds, 0, "code"), Value::Text("007".into())); + assert_eq!(value(ds, 0, "survey"), Value::Text(r#"{"area":10.5}"#.into())); + assert_eq!(value(ds, 0, "buildingPart"), Value::Text("#p1".into())); + let part = layer(&clean, "model BuildingPart"); + assert_eq!(value(part, 0, "parent"), Value::Text("b1, g1".into()), "the link makes it the building's part, and the group's member"); + assert_eq!(value(layer(&clean, "model BuildingRoom"), 0, "parent"), Value::Text("b1".into())); + assert_eq!(value(layer(&clean, "model CityObjectGroup"), 0, "groupMember"), Value::Text(r##"["#b1","#p1"]"##.into())); + assert!( + says(&clean, "1 members of groups (groupMember) have a role in their group"), + "a blank role isn't one: {:?}", + messages_of(&clean) + ); + for text in ["CityObjectRelation", "(versionMember, versionTransitionMember)", "have no name", "codeSpace"] { + assert!(!says(&clean, text), "{text}: {:?}", messages_of(&clean)); + } + // A relation to another object, and the model's versions: left out, and said. + let terrain = "0 0 0 10 0 0"; + let relation = r##"adjacent + lost + setlist + lost too + "##; + let versions = r#""#; + let members = format!("{building}{relation}{terrain}{}{versions}", three(&box_surfaces("b2"))); + let out = read("model.gml", &model3("EPSG:4326", &members), None).unwrap(); + assert!(says(&out, "1 relations between city objects (CityObjectRelation) aren't read"), "{:?}", messages_of(&out)); + assert!( + says(&out, "the file's versions (versionMember, versionTransitionMember) aren't read: 2 are left out"), + "{:?}", + messages_of(&out) + ); + assert!(says(&out, "1 terrain intersection curves (where objects meet the ground) aren't read"), "{:?}", messages_of(&out)); + assert!( + says(&out, "2 generic attributes (genericAttribute, or a member of a genericAttributeSet) have no name"), + "{:?}", + messages_of(&out) + ); + assert!(says(&out, "1 sets of generic attributes (genericAttributeSet) name a code list (codeSpace)"), "{:?}", messages_of(&out)); + assert_eq!(layer(&out, "model Building").features.len(), 2); + assert!(out.iter().all(|(ds, _)| ds.geometry_type == GeometryType::Polygon), "the curve isn't drawn as a line"); +} + +/// The names 3.0 adds are read only in its namespaces: an extension (ADE) of a 2.0 model may name a +/// property of its own `boundary` or `buildingPart`, and it keeps the meaning it had in 2.0. Its +/// feature in `boundary` is an object of its own, not the building's thematic surface, and its +/// `buildingPart` is a link kept as an attribute, which makes no part. +#[test] +fn an_extension_of_2_0_keeps_its_own_properties_named_as_3_0s() { + let ade = r#"xmlns:ade="http://example.com/ade""#; + let inner = format!( + r##"{}{} + "##, + box_surfaces("b1"), + polygon("s1-g", &square(20.0, 20.0, 2.0, 0.0)) + ); + let members = format!("{}{}", building("b1", &inner), building("p1", &box_surfaces("p1"))); + let out = read("model.gml", &lonlat(&members), None).unwrap(); + let sensors = layer(&out, "model Sensor"); + assert_eq!(value(sensors, row_of(sensors, "s1"), "parent"), Value::Text("b1".into()), "{:?}", messages_of(&out)); + let buildings = layer(&out, "model Building"); + assert_eq!(value(buildings, row_of(buildings, "p1"), "parent"), Value::Null, "no part made"); + assert_eq!(value(buildings, row_of(buildings, "b1"), "buildingPart"), Value::Text("#p1".into())); +} diff --git a/docs/user-guide/data-formats.md b/docs/user-guide/data-formats.md index 87bb31406e..387581c8d6 100644 --- a/docs/user-guide/data-formats.md +++ b/docs/user-guide/data-formats.md @@ -30,7 +30,7 @@ not every EPSG code; azimuthal equidistant systems such as Equi7 need the deskto | ArcGIS feature-service answers (protocol buffer) | `.pbf` holding an answer to an ArcGIS query with `f=pbf`, or the query's address | Add Data, drop the file, upload, or From URL… with the query's address (`…/FeatureServer/0/query?…&f=pbf`) | One page of the layer: the fields and values the same query gives as GeoJSON, with the fields' aliases as their display names (dates as milliseconds since 1970, date-only and time values as text), points, lines or polygons converted to longitude/latitude from the answer's coordinate system. Z and M values, geometry, blob and raster fields are left out, with a notice. A page that stopped at the service's record limit keeps its features, with a notice that the rest aren't in it. A query the service refuses (an empty answer), a count, ids or an extent, curves, multipatches and envelopes give an error. Told from OpenStreetMap data by its content. | | TopoJSON | `.topojson`, or `.json` | Add Data, drop the file, or upload | Shared arcs (quantized or not) are rebuilt into geometries. A `.topojson` adds a layer per object, up to 64; a topology named `.json` adds its first object and names the others in a notice. Use `.topojson` to add them all. | | CityJSON | `.city.json`, or `.json` | Add Data, drop the file, upload, or From URL… | CityJSON 1.1 and 2.0, read in 2D: a layer per City Object type and geometry family (a name two layers would share, such as two long types cut to their first 64 characters, or two that differ only in ASCII case, gets ` (2)`, ` (3)`… on the later ones: the first number no other layer's name uses). Surfaces and solids become footprints (LoD 0, else the `GroundSurface` surfaces, else the union of the faces of the highest LoD, each tried when the one before gives no area, else the outline of the points; lines and points come from their highest level of detail that draws; a level passed over because its X or Y isn't a finite number, or is too large, is named in a notice; a geometry of more than 200,000 faces is the outline of its points (of its ground's, for a footprint from the ground), with a notice, unless its footprint is its ground and all of its ground faces are within the cap), with `z_min`, `z_max` and `height` fields, from every level of detail and the children's heights included, so Style › Extrusion stands them up. Also `id`, `type`, `parent`, `lod` and the object's attributes; one named as one of these fields, or as another attribute of its layer but for case, takes a number (`height_1`), the same in every row, and a notice lists them. A `.city.json`, or a model from an address, adds every layer, up to 64; a file named `.json` adds its first layer with something to draw and names the others in a notice. A file that names no coordinate system and isn't longitude/latitude is refused: for now the way to add it is the `"crs"` parameter of `layer.addData`, from the command line, Python or the AI Assistant. Geometry instances are their template placed by their matrix at their reference point, with its heights, and rings the matrix flattens are left out and said for each instance; one whose template is missing, can't be read or draws nothing, or whose matrix is missing or isn't 16 numbers ending in `0 0 0 1`, is drawn as a point at its reference point, with no height, as are those past what placing may cost (as many points, all instances together, as the file could write out), and a notice says how many. `TINRelief` objects aren't drawn; a notice says so, as it does for addresses. Appearance (materials and textures) isn't read, and a notice says how much is left out. Heights are kept in the file's unit: in a coordinate system that doesn't measure in metres, a notice says so, as Style › Extrusion reads metres. In a zip, a `"crs"` applies only to a model that names no coordinate system RustGIS knows. In the browser a footprint that needs a union is the outline of the object's points; a notice says so. Extrusions have no base height yet, so a part above the ground stands on the ground. | -| CityGML | `.gml`, or `.xml` | Add Data, drop the file, upload, or From URL… | CityGML 1.0 and 2.0, read in 2D as CityJSON is (the same layers, fields, footprints, heights and notices). The objects are the features of the model's members and those nested in them with a `gml:id` or a geometry (a `BuildingPart`, a `Room`), each with its parent's id in `parent`; thematic surfaces and their openings are their object's faces, and a `GroundSurface` its ground. A geometry's level of detail is the one its property names (`lod2Solid` is 2); one in another property (a group's) has none. Converted from the `srsName`, by its horizontal part for a compound system (the URN and URL forms of geographic systems are latitude first, CRS84 longitude first), or from the coordinate system given (`crs`), which takes the place of the one the file names; a file naming different systems (on its geometries or envelopes) is refused unless a system is given, which reads them all and says how many named another, and one system with its axes in different orders is refused either way. Picked by name (`layer`), a layer keeps the notices the file as a whole gives; zipped, a model keeps the system it names, and the one given applies only when it names none RustGIS knows. Generic attributes are typed by their element, `measuredHeight`, the storey counts, years and any property with a unit in metres are numbers (a measure in another unit than the metre is text with its unit), other simple properties are text (the code list a code names, `codeSpace`, a value's other attributes, such as its language, `xml:lang`, and a generic attribute set's members with no name aren't kept, and notices say how many, generic attributes included), a property given twice is a list and a structured one its JSON. Each member of the model is parsed on its own, with the objects nested in it (each object of a `featureMembers` on its own), so no tree of the whole model is built; the file's text and the rows read stay in memory. On the desktop, Add Data reads a file added by its path in the background, with its progress counted a member at a time and Cancel (in a zip, from text, or listed, it is read as the command runs). A member nested too deep or too large to parse is left out whole, with a notice. A geometry given by a link (`xlink:href`) to one written in the file, in the same member or another, as a solid's faces are to its walls' and roof's polygons, is read where the link stands, once its object's own geometries are read, a ground surface's links first: one its object holds already at that level of detail isn't read again (a ground face stays its ground, and a face read as a wall that a ground surface links to is read as the ground too), through links each is read at most once per object and level, so links in a cycle end, and what a member's links read is bounded by the member's size, and what links copy and read from other members by four times the file's, past which the links left are said; a solid whose exterior is a link that is followed and reads something keeps its cavities; a link to a `gml:id` that several elements have reads the one in its member, else the first in the file, and a notice says how many geometries repeat one; a geometry whose coordinates can't be read is said once, whichever object or link reads it first. An implicit geometry is its prototype (`relativeGMLGeometry`, written in place or given by a link, in its member or another) placed by its matrix at its reference point, in the file's axis order (latitude first where the system is), with its heights: the prototype is read once and placed for each instance, and rings its matrix flattens are left out and said for each instance; one whose prototype is in another file (`libraryObject`), can't be read or holds nothing to place, or whose matrix isn't 16 numbers ending in `0 0 0 1`, is drawn as a point at its reference point, with no height, as are those past what placing may cost (as many points, all instances together, as the file could write out), and a notice says how many. A part, a group's member or a group's parent given by a link (`consistsOfBuildingPart`, `groupMember`, a `CityObjectGroup`'s `parent`) makes the object it names a child of the other, as if written in it, so its heights go to it, wherever it is in the file (an object written in a group's `parent` is the group's parent too, not its child); the link stays an attribute too, a link naming no other object of the file is said, and a member's role in its group isn't kept, and is said. Not read, and said in a notice: geometries given by a link to another file, nothing or a member that can't be parsed, to what isn't a geometry, or to one where nothing is drawn (an appearance's, a terrain intersection's), a prototype's geometry linked from outside its implicit geometry, and links inside a prototype; thematic surfaces and openings given only by a link; rings given by one (a hole so given is left out, its face kept), lines and rings with a point or curve given by one, and an oriented curve whose base curve is, terrain intersection curves, appearances, addresses, and the properties of thematic surfaces and openings (a name, generic attributes: their faces are kept as their object's); arcs and splines are read as straight lines through their points (a curve given backwards, `orientation="-"`, in its direction, and one held in a ring counted like a standalone one); an arc given by its centre (`ArcByCenterPoint`, `CircleByCenterPoint`) isn't read as the curve's points, its centre is never a vertex, and an arc that is its curve's only segment leaves the geometry with nothing to read; a `gml:Point` written with more than one position keeps the first one, and is said; a solid with no exterior shell is left out, as is a solid whose exterior has nothing read (a link that isn't followed, an empty shell, or a shell whose surfaces are all links that lead nowhere), its cavities with it (read alone they would be drawn as a footprint), and one whose cavity can't be read is left out whole; a file cut short, even inside a tag, keeps the objects before the cut; `TINRelief` objects aren't drawn. CityGML 3.0 is refused. | +| CityGML | `.gml`, or `.xml` | Add Data, drop the file, upload, or From URL… | CityGML 1.0, 2.0 and 3.0, read in 2D as CityJSON is (the same layers, fields, footprints, heights and notices). 3.0 is read by the names it keeps and by its own where they change (thematic surfaces in `boundary`, openings in `fillingSurface`, generic attributes named by `gen:name`, a group's member inside its `Role`), read only in 3.0's namespaces, so an extension of a 1.0 or 2.0 model that uses one of those names keeps its own meaning; its spaces (a `BuildingRoom`, a `Storey`) are objects like any other. The objects are the features of the model's members and those nested in them with a `gml:id` or a geometry (a `BuildingPart`, a `Room`), each with its parent's id in `parent`; thematic surfaces and their openings are their object's faces, and a `GroundSurface` its ground. A geometry's level of detail is the one its property names (`lod2Solid` is 2); one in another property (a group's) has none. Converted from the `srsName`, by its horizontal part for a compound system (the URN and URL forms of geographic systems are latitude first, CRS84 longitude first), or from the coordinate system given (`crs`), which takes the place of the one the file names; a file naming different systems (on its geometries or envelopes) is refused unless a system is given, which reads them all and says how many named another, and one system with its axes in different orders is refused either way. Picked by name (`layer`), a layer keeps the notices the file as a whole gives; zipped, a model keeps the system it names, and the one given applies only when it names none RustGIS knows. Generic attributes are typed by their element, `measuredHeight`, the storey counts, years and any property with a unit in metres are numbers (a measure in another unit than the metre is text with its unit), other simple properties are text (the code list a code names, `codeSpace`, a value's other attributes, such as its language, `xml:lang`, and a generic attribute set's members with no name and its own code list aren't kept, and notices say how many, generic attributes included), a property given twice is a list and a structured one its JSON. Each member of the model is parsed on its own, with the objects nested in it (each object of a `featureMembers` on its own), so no tree of the whole model is built; the file's text and the rows read stay in memory. On the desktop, Add Data reads a file added by its path in the background, with its progress counted a member at a time and Cancel (in a zip, from text, or listed, it is read as the command runs). A member nested too deep or too large to parse is left out whole, with a notice. A geometry given by a link (`xlink:href`) to one written in the file, in the same member or another, as a solid's faces are to its walls' and roof's polygons, is read where the link stands, once its object's own geometries are read, a ground surface's links first: one its object holds already at that level of detail isn't read again (a ground face stays its ground, and a face read as a wall that a ground surface links to is read as the ground too), through links each is read at most once per object and level, so links in a cycle end, and what a member's links read is bounded by the member's size, and what links copy and read from other members by four times the file's, past which the links left are said; a solid whose exterior is a link that is followed and reads something keeps its cavities; a link to a `gml:id` that several elements have reads the one in its member, else the first in the file, and a notice says how many geometries repeat one; a geometry whose coordinates can't be read is said once, whichever object or link reads it first. An implicit geometry is its prototype (`relativeGMLGeometry`, `relativeGeometry` in 3.0, written in place or given by a link, in its member or another) placed by its matrix at its reference point, in the file's axis order (latitude first where the system is), with its heights: the prototype is read once and placed for each instance, and rings its matrix flattens are left out and said for each instance; one whose prototype is in another file (`libraryObject`), can't be read or holds nothing to place, or whose matrix isn't 16 numbers ending in `0 0 0 1`, is drawn as a point at its reference point, with no height, as are those past what placing may cost (as many points, all instances together, as the file could write out), and a notice says how many. A part, a group's member or a group's parent given by a link (`consistsOfBuildingPart`, `buildingPart`, `bridgePart` and `tunnelPart` in 3.0, `groupMember`, a `CityObjectGroup`'s `parent`) makes the object it names a child of the other, as if written in it, so its heights go to it, wherever it is in the file (an object written in a group's `parent` is the group's parent too, not its child); the link stays an attribute too, a link naming no other object of the file is said, and a member's role in its group isn't kept, and is said. Not read, and said in a notice: geometries given by a link to another file, nothing or a member that can't be parsed, to what isn't a geometry, or to one where nothing is drawn (an appearance's, a terrain intersection's), a prototype's geometry linked from outside its implicit geometry, and links inside a prototype; thematic surfaces and openings given only by a link; rings given by one (a hole so given is left out, its face kept), lines and rings with a point or curve given by one, and an oriented curve whose base curve is, terrain intersection curves, appearances, addresses, and the properties of thematic surfaces and openings (a name, generic attributes: their faces are kept as their object's); arcs and splines are read as straight lines through their points (a curve given backwards, `orientation="-"`, in its direction, and one held in a ring counted like a standalone one); an arc given by its centre (`ArcByCenterPoint`, `CircleByCenterPoint`) isn't read as the curve's points, its centre is never a vertex, and an arc that is its curve's only segment leaves the geometry with nothing to read; a `gml:Point` written with more than one position keeps the first one, and is said; a solid with no exterior shell is left out, as is a solid whose exterior has nothing read (a link that isn't followed, an empty shell, or a shell whose surfaces are all links that lead nowhere), its cavities with it (read alone they would be drawn as a footprint), and one whose cavity can't be read is left out whole; a file cut short, even inside a tag, keeps the objects before the cut; `TINRelief` objects aren't drawn; 3.0's relations between objects (`CityObjectRelation`) and the model's versions (`versionMember`, `versionTransitionMember`) aren't read. | | AutoCAD DXF | `.dxf` (ASCII) | Add Data, drop the file, or upload | Points, lines and polygons layers from the drawing's entities: POINT, LINE, LWPOLYLINE and POLYLINE (bulges drawn as arcs; closed ones stay lines; polyface meshes become polygons), CIRCLE, ARC, ELLIPSE, SPLINE, HELIX, LEADER, MLINE (its centre line), TEXT, MTEXT, ATTRIB and constant ATTDEF (points with their text, at the alignment point of justified text), HATCH boundaries (holes found by nesting), SOLID, TRACE and 3DFACE (polygons). Blocks (named in any case) are drawn where INSERTs place them (scaled, rotated, in arrays, nested up to 8 deep), and so are DIMENSIONs' blocks (a linear dimension without one draws its lines and measured text). Entities in an object's own coordinate system are turned into the drawing's. Fields: `layer`, `entity`, `color` (ACI, BYLAYER and BYBLOCK resolved), `linetype`, `text`, `height`, `rotation`, `block`, `elevation` and `paperspace`. The drawing's layouts (paper space: title blocks, viewport frames) are left out, with a notice, unless `"paperSpace": true`. A drawing never says its coordinate system: give `"crs"` (such as `EPSG:2263`), or its coordinates are kept as they are, with a notice. `"layer"` picks one of the drawing's own layers, and `info.fileLayers` lists them. Up to 2 million features (500,000 in the web app). Not read: binary DXF, MULTILEADER, WIPEOUT, IMAGE and ACIS solids (3DSOLID, REGION), named in a notice. | | Geotagged photos | `.jpg`, `.jpeg` | Add Data (several at once in the web app), drop them, upload, or `layer.addPhotos` with `"paths"` or a `"folder"` | JPEGs with a GPS position in their EXIF become points in the **Photos** layer (photos added one at a time join it): each with its `name`, `file`, `time` (when it was taken), `altitude`, `direction` (where the camera faced), `camera` and a `thumbnail` of at most 160 pixels, kept with the feature so the project needs no other file. Identify shows the thumbnail. Photos without a position are named in a notice and left out; a layer holds up to 2,000 photos. A JPEG is always read as a photo unless `layer.addData` or `layer.addDataBytes` is given `"as": "scan"` (a phone photo of a paper map, say: see [Scans with no coordinates](#rasters)). | | LiDAR point clouds | `.las`, `.laz` (COPC too) | Add Data, drop the file, upload, or From URL… | LAS 1.0–1.4 (point formats 0–10) and LAZ, on desktop and web: points with `z`, `intensity`, `classification`, `return` and colour (`red`, `green`, `blue`), coloured by ASPRS class or elevation. An evenly spread sample is read once, at most 2 million points (500,000 in the web app); views use that sample, not the COPC spatial index. LAZ decompression reads at most the first 400 million points (40 million on the web), with a notice when capped. Converted from the file's WKT or GeoTIFF-key record; without one, coordinates are kept with a notice. A local project keeps the path; uploads keep the file bytes. Remote files download whole. |