This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This repository translates the OGC SWE Common Data Model 3.0 (standard OGC 24-014) into multiple binary encoding IDLs, one per subdirectory:
| Directory | File | Format |
|---|---|---|
capnproto/ |
sweCommon3.capnp |
Cap'n Proto |
flatbuffers/ |
sweCommon3.fbs |
FlatBuffers |
protobuf/ |
sweCommon3.proto |
Protocol Buffers (proto3) |
All schemas cover the same ten packages from the OGC spec and must stay in sync with each other. New encodings should follow the same subdirectory convention.
Cap'n Proto (generates language bindings):
capnp compile -o<language> capnproto/sweCommon3.capnp # e.g. -oc++, -ojavaFlatBuffers (generates language bindings):
flatc --<language> flatbuffers/sweCommon3.fbs # e.g. --cpp, --java, --pythonProtocol Buffers (generates language bindings):
protoc --<language>_out=<dir> --proto_path=protobuf protobuf/sweCommon3.proto # e.g. --cpp_out, --java_out, --python_outA Makefile wraps all three compilers (make all, make capnproto, make flatbuffers, make protobuf). Generated code lands in gen/<format>/. Compilation is the primary verification step.
Both schemas mirror the OGC UML package layout:
- Basic Types —
AbstractSWE,AbstractSWEIdentifiable,UnitReference,NumberOrSpecial,DateTimeOrNumber, nil value types, constraint types (AllowedValues,AllowedTokens,AllowedTimes),AssociationAttributeGroup - Abstract Data Component hierarchy —
AbstractDataComponent,AbstractSimpleComponent - Simple (Scalar) Components —
Boolean,Count,Quantity,Text,Category,Time - Range Components —
CountRange,QuantityRange,TimeRange,CategoryRange - Polymorphic unions —
AnyScalarComponent,AnySimpleComponent,AnyComponent,NamedComponent - Record Components —
DataRecord,Vector - Choice Components —
DataChoice - Block Components —
DataArray,Matrix,DataStream - Geometry Components (new in 3.0) —
Geometry,GeoJsonGeometry,GeometryConstraint - Encodings —
TextEncoding,JSONEncoding,XMLEncoding,BinaryEncoding,AnyEncoding
Inheritance → embedded base structs/tables. Neither IDL supports class inheritance. Every concrete type embeds its abstract base as a named field (base, dataComponent, identifiable) rather than flattening or duplicating fields. This preserves the OGC field hierarchy at each level.
Polymorphism → unions. OGC's AnyComponent, AnySimpleComponent, etc. are expressed as Cap'n Proto unnamed unions / FlatBuffers union types.
DataStream extends AbstractSWEIdentifiable, not AbstractDataComponent — unlike all other composite types. Its values field is always an out-of-band link (AssociationAttributeGroup), not inline data.
- Field ordinals (
@0,@1, …) must never be renumbered or reused — they are the wire format. - The file ID
@0xb3a4f7c8e2d19056must remain stable. NumberOrSpecialandDateTimeOrNumberuse native Cap'n Proto unnamed unions.- There is no declared root type; callers wrap the top-level struct themselves.
- Syntax:
proto3. Package:ogc.swecommon. - Language options set for Java (
org.ogc.swecommon.SweCommonProto) and Go (ogc.org/swecommon). - Enum values use
SCREAMING_SNAKE_CASEprefixed with the enum name (e.g.,GEOMETRY_TYPE_POINT,BYTE_ORDER_BIG_ENDIAN) per the Protobuf style guide. Every enum has an_UNSPECIFIED = 0sentinel. oneofis used for all polymorphic associations (AnyComponent,ComponentOrRef,AnyEncoding, etc.). Proto3oneofcannot containrepeatedfields, soAllowedTokensuses a nestedTokenListmessage wrappingrepeated string.optionalkeyword is used on scalar fields where presence tracking matters (e.g.,Boolean.value,Count.value,AbstractDataComponent.is_optional).- The OGC field name
optionalis renamed tois_optionalto avoid collision with the proto3optionalkeyword. - Root message is
SweCommonMessagewith aoneof root { AnyComponent, DataStream }.
- Namespace:
ogc.swecommon. - Root type is
SweCommonMessage { root: SweCommonRoot }— file identifier"SWEC", extension".swe". AnyComponentWrapperexists solely as a workaround: FlatBuffers unions cannot directly contain other unions, soComponentOrRefwrapsAnyComponentin a table first.DateTimeOrNumberuses an explicit enum discriminator (DateTimeKind) + separate fields because FlatBuffers tables cannot have inline unions of scalar/string combinations the way Cap'n Proto can.AllowedTokenssimilarly uses aAllowedTokensKindenum discriminator instead of a union.- Fields marked
(required)enforce non-null at serialisation time.