Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions example_types_io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ func ExampleTGeomPointFromHexEWKB() {
// POINT(1 1)@2024-12-06 00:00:00+00 <nil>
}

func Example_sequenceAtGeometry() {
// A sequence carries the methods of its leaf, and a geometry argument is
// a *Geo: TGeomPointSeq reaches TPoint.AtGeom through TGeomPoint, whose
// restriction MEOS answers as a sequence set. It reads the value as
// #ExampleTGeomPointFromText does.
temp, _ := types.TGeomPointFromText("[Point(0 0)@2024-12-06, Point(2 0)@2024-12-08]")
seq := types.TGeomPointSeqFromPointer(temp.Pointer())
box, _ := types.GeometryFromText("Polygon((0 -1,1 -1,1 1,0 1,0 -1))", 0)
at, err := seq.AtGeom(&box.Geo)
fmt.Println(types.TGeomPointFromPointer(at.Pointer()), err)
// Output:
// {[POINT(0 0)@2024-12-06 00:00:00+00, POINT(1 0)@2024-12-07 00:00:00+00]} <nil>
}

func Example_cbufferString() {
cbuffer, _ := types.CbufferFromText("Cbuffer(Point(1 1),0.5)")
fmt.Println(cbuffer)
Expand Down
15 changes: 15 additions & 0 deletions tools/objectgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def zero(go_type: str) -> str:
return "0"


# The suffix a concrete class takes for each template subtype, as MEOS.NET's
# tools/objectgen.py names them.
SUBTYPE_SUFFIX = {"TInstant": "Inst", "TSequence": "Seq", "TSequenceSet": "SeqSet"}


class Model:
"""The class hierarchy the catalog defines, indexed for emission."""

Expand Down Expand Up @@ -129,6 +134,16 @@ def _build(self) -> None:
if cls:
self.parent[cls] = "Temporal"

# A concrete class is `<leaf><suffix>` and embeds its leaf, so it
# carries the leaf's family surface (TGeomPointSeq the methods of
# TGeomPoint), as #_build of MEOS.NET's tools/objectgen.py makes the
# leaf its base.
for leaf in [n for n, v in self.om["lattice"].items()
if isinstance(v, dict) and v.get("kind") == "leaf"]:
for suffix in SUBTYPE_SUFFIX.values():
if leaf + suffix in self.om["classes"]:
self.parent[leaf + suffix] = leaf

for family in [k for k in self.om["companions"] if not k.startswith("_")]:
for name, node in self.om["companions"][family]["nodes"].items():
if name.startswith("_"):
Expand Down
10 changes: 5 additions & 5 deletions types/cbuffer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading