Repository navigation
Description
Before you start
- I searched the existing issues and the roadmap and did not find a duplicate request.
What problem does this solve?
SketchUp and Google Earth exchange 3D buildings as KMZ. A KML <Placemark> holds a <Model>
that places a COLLADA mesh (a .dae inside the KMZ) at a longitude and latitude, turned by a
heading and scaled.
This is now a required format for planning review in Taiwan:
- Tainan: from 2027-01-01, an urban design review application must upload a building 3D
model and a 2D site layout model, each a KMZ exported from SketchUp, at most 10 MB, in metres,
with JPG textures (Tainan Q&A, Q3). - Taoyuan's public manual gives the same rules (p. 4). It builds the 2D site layout model in
SketchUp Make 2017 as a 0.1 m slab that carries the site plan as one JPG, and exports it as a
Google Earth KMZ (pp. 23, 28;
manual). - Taichung takes 3D building models as KMZ for its review map, and asks for simple massing
models, not detailed models converted to KMZ (p. 18 of the
manual). - Taiwan's national LOD1 building models (NLSC) are supplied as KMZ
(sample programme). I haven't
opened one: they may hold<Model>meshes or extruded KML polygons, and only the first is this
request's case.
Reviewers, applicants and researchers want to see these models with the other layers of a
review: zoning, cadastre, the neighbours' approved cases.
Today RustGIS skips every <Model> placemark. A KMZ that holds only models fails, and the
message doesn't say why:
$ rustgis-cli info MackyBldg.kmz # main 463133bd
rustgis-cli: layer.addData: …/MackyBldg.kmz: nothing to draw
MackyBldg.kmz is a SketchUp export from Google's KML documentation
(file).
GDAL doesn't read <Model> geometry either: the LIBKML driver's kml2geom_rec handles Point,
LineString, LinearRing, Polygon, MultiGeometry, gx:Track and gx:MultiTrack only. QGIS reads KML
through GDAL, and its 3D model symbols take OBJ, glTF and FBX, not COLLADA
(QGIS docs).
I found no issue or discussion that asks for this (I searched KMZ, KML, COLLADA, SketchUp, glTF,
"3D model" and "Google Earth"). I don't know the maintainers' view of 3D work that isn't on the
roadmap, so I'm asking here before I write the reader.
Why it fits RustGIS now. RustGIS already reads 3D city models in 2D. CityJSON (#1269),
CityGML and File Geodatabase multipatches become footprints with z_min, z_max, height and
base_height, through the shared footprint (crates/data/src/footprint.rs), and come in
standing (SuggestedExtrusion, then stand() in crates/engine/src/cmd/layer.rs). A KMZ model
is the same idea for the exchange format of SketchUp and Google Earth. It doesn't wait on 3D
scenes (#726).
Proposed solution
Two pull requests.
Slice 0: say why there is nothing to draw. When a KML or KMZ has no placemark RustGIS draws,
the error names what it skipped, for example MackyBldg.kmz: nothing to draw: 1 placemark is a 3D model (<Model>), which RustGIS doesn't read. In a file with other placemarks, the existing skip
notice says how many of the skipped placemarks are models. Tests: both messages, and no change
for a file without models.
Slice 1: read a model as a standing footprint.
- Find the mesh.
<Link><href>is resolved inside the KMZ against the KML's folder, as
ground overlay pictures are (ignoring case; an escaped name such asCU%20Macky.daetoo).
For a plain.kml, a.daebeside it in its folder, as for ground overlays (not a web
address, not outside the folder). - Read the mesh. A new
crates/data/src/collada.rsparses throughcrate::xml, with its
node and depth limits. It reads COLLADA 1.4.1 and 1.5:<triangles>,<polylist>,
<polygons>(holes in<ph>),<trifans>and<tristrips>; the scene's node tree with
<matrix>,<translate>,<rotate>and<scale>;<instance_geometry>and
<instance_node>(from<library_nodes>, depth-limited, cycles stopped); and
<asset><unit meter>and<up_axis>(COLLADA's default is Y up; SketchUp writes Z up and
inches). - Place it. Model units become metres and the up axis becomes Z. Then the KML
<Scale>and
<Orientation>(heading, tilt and roll as the
KML reference
defines them; tests pin their order and signs) give metres east, north and up of
<Location>. - Footprint. The shared
footprintmakes the union in those local metres (its face-tilt
test needs X, Y and Z in one unit). Its vertices then become longitude and latitude by a
projection centred on<Location>. No such helper exists yet.terrio-crs, already a
dependency, reads PROJ definitions withtmerc, so a transverse Mercator centred on the model
may do it with no new formula (to confirm). Otherwise a small ellipsoidal formula is added,
not the spherical haversine that AGENTS.md bans. - Rows and fields. One row per
<Model>, in a polygon layer of its own (<name> models),
so the file's flat polygons don't stand up with the models. The fields are the usual KML
columns (name, description, folder, style, extended data),model(the href), andz_min,
z_max,heightandbase_heightas in CityJSON. Heights are metres above the model's
ground forclampToGroundandrelativeToGround, and above sea level forabsolute.
base_heightis 0, as for a building in CityJSON. The layer comes in standing
(SuggestedExtrusion). - Fallback. A model whose mesh is missing, can't be read or passes a limit is a point at its
<Location>, in the points layer, with no height. A notice counts these models.
Limits, said in notices and in the format table.
- Massing. One footprint per model, raised to its top. A podium with a tower stands as one
block as tall as the tower. Rows per top-level node (like CityJSON's parts) can follow. - Appearance. Textures and materials aren't read. One notice counts the pictures left out
(20 in the sample). - Not read, and counted: lines (
<lines>,<linestrips>), controllers
(<instance_controller>), and meshes in another file (aurlthat doesn't start with#). - The 2D site layout model of a review (a 0.1 m slab that carries the site plan as a
picture) is read as its outline, 0.1 m tall. The plan picture isn't shown.
Bounds and the UI thread. KML and KMZ are read on the UI thread, within the decompression
budget io::BYTES_FLOOR (#2408). A model's .dae comes out of the same budget. Each .dae is
parsed within the XML node and depth limits. A model of more than 200,000 faces is the outline of
its points, as in CityJSON. Unions keep MAX_UNION_FACES and the shared budget of footprint
(#1891). A notice says when a cap applies.
Crates and dependencies. crates/data: kml.rs (Model placemarks, .dae entries from the
KMZ), a new collada.rs, and the helper from step 4. crates/engine: tests only; stand()
applies a layer's SuggestedExtrusion when the layer is added (to confirm on the KMZ path, which
adds several layers). No new dependency (roxmltree through crate::xml, and RustGIS's own
zip.rs). No change to the data model, the .rgis format, or a command's id or parameters.
#2764 reworks notices and loss codes in kml.rs, so this work starts after it merges.
Tests.
collada.rsunits on hand-written meshes: the unit, Y up, a node matrix with an instance
node, polylist and polygons with holes, inputs at several offsets, an index past the end and a
bad number (skipped and counted, never a panic), and an instance cycle.- Placement on an asymmetric L-shaped model with heading 90°, scale (2, 1, 1) and
relativeToGround: the footprint's corners and heights match values worked out by hand (to
1 cm). - KMZ: an href with a space and with
%20, a match that ignores case, and a missing.dae(a
point and a notice). never_silent_reading: a textured model gives the textures notice with its count; an
untextured model gives none.- Engine: the models layer comes in standing.
- Fuzz: a
.daeand a model KMZ as seeds forread_layers. - By eye:
MackyBldg.kmz(its licence isn't stated, so it isn't committed), drawn over a
basemap, sits on Macky Auditorium in Boulder.
Docs. The KML/KMZ row of docs/user-guide/data-formats.md, and the loss code table of
docs/cli.md if codes are added.
Not in this work. True 3D drawing of meshes (#726, #2745), textured faces as pictures on the
map, SketchUp .skp and IFC (Taipei's review takes these), a review-rules checker (size, JPG
textures, names, location), and writing <Model> on export.
What I haven't seen. One sample only: Google's 2006 SketchUp export. I have no export from a
current SketchUp (Taoyuan's manual uses SketchUp Make 2017) and no review KMZ from Tainan,
Taoyuan or Taichung. Slice 1 is checked on a current export before it is marked ready.
Questions for maintainers.
- Is this in scope now, given that the roadmap's 3D scenes section puts "3D objects" after
scenes? - Should a KMZ with models be read in the background with progress and Cancel, as CityGML is?
- Should left-out models and textures get loss codes (for example
dropped.model)? - Is
<name> modelsa good name for the models layer?
Estimated scope
Medium: a broader feature that is feasible in a reasonable timeframe
Alternatives considered
- Convert outside RustGIS: unzip the
.daeand convert it to another mesh format. RustGIS doesn't
add OBJ or glTF meshes as layers either, and the KML placement (location, heading, scale) is
lost on the way. - Export footprints from SketchUp to a Shapefile: this needs a plugin, and the heights are lost.
- Wait for 3D scenes ([Feature]: Full 3D scenes: heights in the data, 3D objects and point clouds, a scene camera #726) and draw the meshes: larger and later. Footprints serve 2D review
maps now, and stay useful when scenes come.
Activity