Site Context (Switzerland)¶
Real terrain, the cadastral parcel and the neighbouring buildings around a
georeferenced Swiss building model, as one GLB in a frame stated in
EPSG:2056 (LV95) with LN02 (EPSG:5728) heights, plus a JSON summary.
The data comes from the federal geodata services: swissALTI3D terrain
read straight from the cloud-optimised tiles and the cantonal cadastral web
map for the parcel, with its ÖREB extract link, through
@ifc-lite/geodata-ch; and swissBUILDINGS3D buildings from swisstopo's
3D Tiles through @ifc-lite/tiles3d.
This is the headless core. Showing the context in the viewer and writing it into IFC build on the same document and GLB format.
In the viewer¶
The Site context section of a model's Georeference panel (in the
Information panel) loads the same layers around a georeferenced model. The
Site context ribbon button and the Load site context palette command
open that section; neither fetches anything. Pick a radius (100, 200, 300 or
500 m), the layers to include (Terrain, Parcel, Buildings) and
whether to Drape aerial imagery, then choose Load site context.
Requests go from the browser straight to geo.admin.ch, only on that click.
Each layer arrives as its own federated model that the hierarchy can hide like
any other. A scene holds one model per layer: a layer that loads replaces the
earlier model of the same layer, after the new one is in. A layer you did not
request, or one that fails to load, keeps its earlier model, which may still sit
around a different building; the section names that building when it does. When the model cannot host site context yet (no georeferencing, a
CRS that does not resolve to LV95, another height datum, a site outside
Switzerland), the section says why and what to fix. A deployment that turns
off the privacy.third-party feature hides the section (see
Configuring the Viewer for a Deployment).
Surface runoff¶
Below Site context, the same panel shows a Surface runoff section for an IFC model placed in Switzerland. The Runoff ribbon button and the Surface runoff check palette command open it. It offers two things, each only on a click:
- Drape the overland flow map on the terrain: the federal overland flow map (BAFU) drawn on the loaded site-context terrain, with its legend. It needs the Terrain layer loaded first.
- Run flood check: the
@ifc-lite/flood-checkscreening of doors, windows, openings and equipment near the ground against the depth class the map shows next to them. Pick the Ground storey, or leave it on "Not stated" and the check guesses (a guess allows no favourable outcome). The verdicts colour the checked elements (Colour the checked elements by verdict turns that off) and show in the property panel for this session; they are not written to the model.
It is a screening against a published hazard map, not a flood simulation, and
the map is not legally binding. The section is hidden with the
privacy.third-party feature off, like Site context, because both fetch from
geo.admin.ch.
Attribution is required¶
Every layer carries the attribution its data owners require, in the JSON summary and inside the GLB. Show it wherever the context is shown:
- Terrain: © swisstopo (swisstopo open data: free use including commercial, source reference mandatory).
- Buildings: © swisstopo (swissBUILDINGS3D) (swisstopo open data, as terrain).
- Parcel: © Cadastral surveying (CS) and the cantons. These terms are
not verified: the cantons own the data, and the terms page the
catalogue points to is gone. Check the canton's terms before
redistributing parcel geometry. The parcel layer always carries a
terms-unverifiedissue saying so.
From the CLI¶
ifc-lite site-context model.ifc --radius 300 --layers terrain,parcel,buildings --resolution auto --out context.glb --json
The centre is the model's IfcMapConversion origin (Eastings/Northings,
converted from the map unit to metres). The command needs a map conversion
whose CRS is EPSG:2056. The literal EPSG:2056 is accepted, and so are names
@ifc-lite/geo resolves to it, such as CH1903+ / LV95. The summary says
which form matched. A model in another CRS @ifc-lite/geo can transform,
such as LV03 (EPSG:21781), has only its centre point reprojected, and the
summary says so. A model without a map conversion is refused with a pointer
to adding one (or to --centre E,N). A stated vertical datum other than LN02 is refused
rather than mixing height systems; a model that states none proceeds with a
warning.
The model's rotation and scale are never applied: the context is placed against the model by the model's own georeferencing, the same way federated models are placed.
Without a model:
ifc-lite site-context --centre 2600423,1199521 --radius 100 --out context.glb
ifc-lite site-context --egrid CH294676423526 --radius 150 --out context.glb
| Option | Default | Meaning |
|---|---|---|
--radius M |
150 | Half the side of the square site, metres (max 5000) |
--layers L,... |
terrain,parcel |
Any of terrain, parcel, buildings |
--subject-egid N |
The model's own building among the neighbours, by EGID | |
--tile-requests N |
64 | Request budget of the buildings tile read; cache hits are free |
--resolution R\|auto |
auto |
Terrain node spacing: max(0.5, 2·radius/500) m, rounded up to 1/16 m |
--out F |
required | The GLB to write |
--json |
Print the summary as JSON | |
--cache-dir D |
$XDG_CACHE_HOME/ifc-lite/geodata |
Response cache on disk, keyed by URL and Range; building tiles go in its tiles3d folder |
--offline |
Answer only from the cache; nothing is sent | |
--rate R |
5 | Requests per second per host |
Network access is on by default, at the geodata client's rate limit, and
every response is cached, so a second run of the same site sends nothing.
Every request goes through a swisstopo host allowlist (api3, data, wms,
wmts and 3d.geo.admin.ch, https only): no option names a URL, a URL taken
from a response (a STAC page link, a tileset's content URI) on any other host
is refused before it is sent, and redirects are not followed.
The map conversion's unit comes from IfcProjectedCRS.MapUnit, else the
project length unit. When the map unit reads as metres the summary warns that
metres are assumed: the reader also reports an unreadable MapUnit as
metres, so a declared metre and an unreadable unit look the same.
At --radius 100 around Bundesplatz, Bern (--centre 2600423,1199521), the
terrain comes out as 16 chunks and the skirt at 0.5 m spacing, plus the parcel
with its ÖREB link. The parcel there reaches beyond the 200 m site, so its
ribbon breaks where the terrain ends and the layer reports
parcel-undraped-vertices.
The buildings layer reads swisstopo's tile index JSON files first; they are
large, and the cache keeps them, so a re-run of the same site from the cache is
much faster than the first run. --subject-egid 2242547 marks the Parliament
Building as the subject at that centre. For a 1 km urban site, raise
--tile-requests: when the budget stops the read, the layer is marked
incomplete and says how many tiles were left. Run times and download sizes
depend on the live services, the tileset release and your connection.
The JSON summary has the document origin and CRS, per layer the feature,
triangle and vertex counts, completeness, attribution and issues, plus the
GLB size, the requests made, the cache use, the parcel's EGRID, number and
ÖREB link, and, from a model, which CRS form matched, the map unit and the
model's rotation (with rotationApplied: false). With buildings it adds
buildings: the count, how many have an EGID, the subject and how it was
matched, the tile requests, bytes and cache hits, the triangles per part,
the model footprint used for matching, and the layer's issues.
From TypeScript¶
import { createSwissGeodata } from '@ifc-lite/geodata-ch';
import { buildSiteContext, encodeSiteContextGlb, summarizeSiteContext } from '@ifc-lite/site-context';
const doc = await buildSiteContext({
centre: { x: 2_600_423, y: 1_199_521 },
radius: 100,
layers: ['terrain', 'parcel'],
geodata: createSwissGeodata(),
});
const glb = encodeSiteContextGlb(doc);
for (const layer of summarizeSiteContext(doc).layers) {
console.log(layer.kind, layer.triangles, layer.complete, layer.attribution.map((a) => a.text));
}
What is in the file¶
- One frame. The document origin
[E0, N0, H0]is the centre rounded to whole metres. H0 is the terrain height nearest the centre, rounded, when terrain was read;originHeightthen carries it asterrainHeight. Without terrain (only buildings, or the elevation grid failed)originHeight.terrainHeightisnullwith the reason, and H0 is 0: a frame offset, not a height. Every feature has its own f64 origin and float32 positions relative to it. Local axes are east, north and up; in the GLB they are turned to glTF's Y-up as(east, up, −north). - Terrain in chunks of up to 128 × 128 grid cells, each its own feature
(
IfcGeographicElement,PredefinedTypeTERRAIN), plus a skirt down to 5 m below the lowest point so the terrain reads as a body. Cells without data are left out and counted; no height is ever made up. UVs span the terrain so imagery can be draped later. The source tiles and their year are in the provenance. - Parcel as a 0.3 m ribbon 0.1 m above the terrain (
IfcSite), with attributes laid out forPset_LandRegistration(LandID= EGRID,LandTitleID= parcel number), the computed area, canton, source layer and the ÖREB extract link. A failed ÖREB lookup is an issue on the layer, not a failed run. - Buildings, one
IfcBuildingfeature per swissBUILDINGS3D building object whose footprint touches the site square, kept whole (never cut at the boundary). Each mesh has aroofand awallpart (the tiles' red and beige materials), outward winding and flat normals, so it renders single-sided and casts shadows. Attributes are in theIfcLite_SiteContextBuildingset:EGID(where the canton's tiles have it, elsenull),UUID,ObjectType,TotalHeight,RoofMin,RoofMax,TerrainPoint,DatasetRelease,SourceTile. Ids arebuilding:egid:<EGID>; where the tiles split one building into several objects sharing an EGID, each getsbuilding:egid:<EGID>:uuid:<UUID>, so every id is unique. The model's own building is markedsubject: true(every object of it, when it is split), even past the building and triangle caps, matched by--subject-egid, else by overlap of at least half the smaller footprint with the plan rectangle spanned by the model's element placements (LOD0 boxes: an element'sIfcBoundingBoxwhere it has one, else its placement point), carried through the map conversion, rotation included. That rectangle is coarse; a wall placed at one end can leave it short of the outline. When the buildings layer is built from a model, the parcel is looked up at that rectangle's centre instead of the map conversion origin. The subject is kept: a viewer decides to hide it. Buildings without EGID or heights, and anything capped, are counted in the issues. - Honesty. A layer that could not be completed says
complete: falseand lists its issues. A centre outside Switzerland is refused.
The full format, including how node translations keep full precision, is in
the @ifc-lite/site-context README.