Skip to content

Story - Share the Lexer and Distinguish WKT from Compact EWKT Syntax #27

Closed

Description

@Alexandre-T

WKT and EWKT have to share a lexer that recognizes SRIDs and attached dimension suffixes,
so that each strategy can enforce its own rules and provide clear error messages.

Context

The current lexer is located in the WKT strategy namespace, although it needs to be reusable by the future EWKT strategy. It must recognize SRID=...; and split compact forms such as POINTM, POINTZ, and POINTZM into distinct tokens.

This lexical recognition does not mean that the WKT strategy accepts these compact forms. The OGC Simple Feature Access 1.2.1 WKT grammar represents the dimension marker as a separate element from the geometry type.

Acceptance Criteria

  • The lexer is moved to a namespace shared by the strategies, and the WKT strategy uses it from this namespace.
  • The shared lexer preserves recognition of SRID tokens and the SRID=...; syntax.
  • The shared lexer recognizes M, Z, and ZM suffixes attached to the geometry types it supports. For example, POINTM produces the POINT and M tokens with their correct positions.
  • Forms with a separate dimension marker, such as POINT M, POINT Z, and POINT ZM, remain recognized.
  • The WKT strategy explicitly rejects dimension markers attached to the geometry type, such as POINTM, POINTZ, and POINTZM, instead of producing a generic error or accepting them.
  • The error message indicates that the compact form is not valid according to OGC Simple Feature Access 1.2.1, suggests the WKT form with a separate dimension marker, and recommends using the more permissive EWKT strategy once it is available.
  • Tests cover shared tokenization, preservation of SRID parsing, and explicit rejection by the WKT strategy.
  • Valid WKT syntax, including POINT M (...), continues to be accepted.

Proposed Error Message

The compact dimension suffix in "POINTM" is not valid OGC WKT (Simple Feature Access 1.2.1). Use "POINT M" or consider the more permissive EWKT strategy.

Implementation Notes

The detection of an attached dimension marker must remain a WKT strategy rule; the shared lexer must only produce tokens and their positions.

Preserving the lexer's previous class name through a deprecated compatibility facade would avoid a breaking change for existing consumers. Otherwise, the namespace migration must be treated as an API compatibility decision.

This Story prepares the lexer for reuse by EWKT; it does not deliver the EWKT strategy itself.

Metadata

Metadata

Assignees

Labels

impact:apiAffects the public APIspatial:dimensionRelated to XY, XYZ, XYM or XYZM dimensionsspatial:geometryRelated to geometry models or typesspatial:wktRelated to Well-Known Text or Extended Well-Known Textstandard:ogcRelated to OGC specifications

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions