Documentation
¶
Overview ¶
Package vtcseamless reassembles seamless polygons from a vector-tile cache.
Tile servers clip every feature to the tile it is drawn in, usually WITH A BUFFER of a few pixels so that strokes do not show seams at tile edges. For rendering that is right; for data it is wrong: the per-tile copies of one polygon overlap, their areas double-count along every tile edge, and a plain union of the copies has the wrong area wherever the buffer overlapped a neighbour. The engine in this package applies one rule that makes the problem go away:
- ClipToBound: every piece is clipped back to its own tile rectangle (Sutherland–Hodgman). Tiles tessellate, so the clipped pieces of one feature are DISJOINT, their areas add, and the union cannot double-count.
- UnionPieces: pieces of one feature id are dissolved with polyclip. The result is accepted only if its area agrees with the additive area of the pieces within UnionAreaTol (2 %); otherwise the pieces are kept as they are (a seam remains along the tile edge, but nothing is invented).
- ClassifyRings: polyclip returns a flat, unordered contour list; rings are turned into polygons by nesting depth (even = shell, odd = hole) and oriented shell CCW / holes CW (RFC 7946).
- MergeSeams: for layers WITHOUT a stable feature id, pieces from adjacent tiles that share a stretch of the common edge are unioned when that union really dissolves the seam (fewer polygons out than in).
Everything here is planar lon/lat geometry on orb types; it knows nothing about any particular tile server. Package bevdirect is the preset for the Austrian cadastre tile cache and shows how the pieces fit.
Index ¶
- Constants
- func AreaSqm(mp orb.MultiPolygon) float64
- func ClassifyRings(rings []orb.Ring) []orb.Polygon
- func ClipToBound(poly orb.Polygon, b orb.Bound) orb.MultiPolygon
- func FromPolyclip(p polyclip.Polygon) orb.MultiPolygon
- func RectClip(pc polyclip.Polygon, b orb.Bound) polyclip.Polygon
- func RoundCoords(mp orb.MultiPolygon, dec int)
- func TileSetBound(tiles []Tile) orb.Bound
- func ToPolyclip(p orb.Polygon) polyclip.Polygon
- func ToPolygons(g orb.Geometry) []orb.Polygon
- func UnionPieces(polys []orb.Polygon, targetArea float64) (orb.MultiPolygon, bool)
- type SeamGroup
- type SeamPiece
- type Tile
Constants ¶
const UnionAreaTol = 0.02
UnionAreaTol is the relative area mismatch above which a union is rejected and the pieces are kept as they are.
Variables ¶
This section is empty.
Functions ¶
func AreaSqm ¶
func AreaSqm(mp orb.MultiPolygon) float64
AreaSqm is the area of a lon/lat MultiPolygon in m² on a local tangent plane (ellipsoidal metres-per-degree at the bbox centre; <0.1 % at parcel scale). Holes (rings after the first) are subtracted. It is a geometric area, not a legally binding one.
func ClassifyRings ¶
ClassifyRings assigns shell/hole by nesting depth (even = shell, odd = hole) and normalises orientation (shell CCW, holes CW) — RFC 7946. Input orientation is ignored; containment is tested geometrically. Rings are modified in place (reversed where needed).
func ClipToBound ¶
ClipToBound clips poly to the axis-aligned rectangle b (its own tile) and returns the result as a MultiPolygon with classified rings; nil if nothing is left. This is step 1 of the assembly: pieces clipped to tessellating tiles are disjoint, so their areas add.
func FromPolyclip ¶
func FromPolyclip(p polyclip.Polygon) orb.MultiPolygon
FromPolyclip turns polyclip's flat, unordered contour list into a MultiPolygon by nesting depth (orientation-independent; see ClassifyRings). Degenerate contours (< 3 points) are dropped; nil if nothing remains.
func RectClip ¶
RectClip is Sutherland–Hodgman of each contour against an axis-aligned rectangle. Contours that collapse below 3 points are dropped.
func RoundCoords ¶
func RoundCoords(mp orb.MultiPolygon, dec int)
RoundCoords rounds every coordinate in place to dec decimals.
func TileSetBound ¶
TileSetBound is the union bbox of a tile set.
func ToPolyclip ¶
ToPolyclip converts an orb.Polygon to polyclip's contour list.
func ToPolygons ¶
ToPolygons flattens a geometry to its polygons (Polygon, MultiPolygon, Collection); nil for anything else.
func UnionPieces ¶
UnionPieces dissolves shared tile edges between DISJOINT pieces of one feature (each already clipped to its own tile with ClipToBound). Pieces are first clustered by touching bboxes; each cluster is unioned with polyclip and the union is accepted only if its planar area agrees with the sum of the piece areas within UnionAreaTol — otherwise the cluster's pieces are emitted unchanged. targetArea is the expected total (deg²; the sum of the piece areas as computed by the caller; <= 0 disables the final check). The second result reports whether any guard tripped.
Types ¶
type SeamGroup ¶
type SeamGroup struct {
Members []int
Merged orb.MultiPolygon
}
SeamGroup is one output of MergeSeams. Members are indices into the input (ascending). Merged is the dissolved geometry (coordinates rounded), or nil when the members are to be kept exactly as they were — either because the group is a singleton or because the union did not reduce the polygon count.
func MergeSeams ¶
MergeSeams partitions pieces into groups that belong to one feature split by a tile edge and unions each group. Every input index appears in exactly one group; groups are ordered by their smallest member, so emitting the groups in order preserves the input order for everything untouched. decimals is the coordinate rounding applied to merged geometries.
type SeamPiece ¶
SeamPiece is one tile-clipped feature of an id-less layer: the tile it came from and its polygons (as produced by ClipToBound).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bevdirect assembles cadastral parcels, building footprints and land-use polygons for a bbox DIRECTLY from the BEV vector tiles (Katastralmappe VTC, CC BY 4.0).
|
Package bevdirect assembles cadastral parcels, building footprints and land-use polygons for a bbox DIRECTLY from the BEV vector tiles (Katastralmappe VTC, CC BY 4.0). |
|
cmd
|
|
|
bevdirect
command
bevdirect — fetch Austrian cadastre for a bbox straight from BEV tiles.
|
bevdirect — fetch Austrian cadastre for a bbox straight from BEV tiles. |
|
bevdirect-serve
command
bevdirect-serve — a small cadastre service assembled live from BEV vector tiles.
|
bevdirect-serve — a small cadastre service assembled live from BEV vector tiles. |