Skip to content

GH-4230: Add GeoSPARQL 1.1 geometryN function - #4231

Merged
afs merged 2 commits into
apache:mainfrom
edmondchuc:feat/geosparql/geometry-n-function
Sep 27, 2026
Merged

afs merged 2 commits into
apache:mainfrom
edmondchuc:feat/geosparql/geometry-n-function

Conversation

@edmondchuc

@edmondchuc edmondchuc commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

GitHub issue resolved #4230

Adds GeoSPARQL 1.1 geof:geometryN and GeometryWrapper.getGeometryN(int) to select a direct member of a geometry.

The result preserves the member’s datatype, SRS, and coordinate layout, including when that member is empty.

For example, geof:geometryN("MULTIPOINT ((1 2), (3 4))"^^geo:wktLiteral, 2) returns POINT (3 4) as a WKT literal.

  • Indices are one-based. Nested collections are selected without flattening; index 1 on an atomic geometry returns that geometry.
  • Indices must be xsd:integer or an integer-derived type. Invalid indices and geometry arguments raise SPARQL expression errors. An empty collection has no selectable member.
  • WKT and GML reading and writing preserve empty members instead of serializing an all-empty collection as though it had no members. WKT also retains Z/M/ZM markers and rejects missing or unbalanced members.

The parser and writer changes are needed because selecting a member must produce a literal that can be serialized and read again without losing its structure or dimensions.

The tests cover selection and errors through SPARQL, plus direct WKT/GML round trips and dimension handling in the existing reader, writer, and geometry test classes.


  • Tests are included.
  • Documentation change and updates are provided for the Apache Jena website
  • Commits have been squashed to remove intermediate development commit messages.
  • Key commit messages start with the issue number (GH-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.


See the Apache Jena "Contributing" guide.

@edmondchuc
edmondchuc force-pushed the feat/geosparql/geometry-n-function branch 4 times, most recently from 37b5b05 to 4a6c59c Compare September 17, 2026 10:52
@afs

afs commented Sep 21, 2026

Copy link
Copy Markdown
Member

I see changes to the GML and WKT readers and writers.

Is existing the test suite coverage (org/apache/jena/geosparql/implementation/parsers/) sufficient?

@edmondchuc
edmondchuc force-pushed the feat/geosparql/geometry-n-function branch from dfebf60 to 1553c96 Compare September 26, 2026 02:33
@edmondchuc

Copy link
Copy Markdown
Contributor Author

I’ve updated the tests so that the WKT and GML reader/writer changes are now in their existing parser test classes.

@afs afs added the GeoSPARQL label Sep 26, 2026
@afs

afs commented Sep 26, 2026

Copy link
Copy Markdown
Member

Do you want to keep as 2 commits or can we squash-and-merge this PR?

@edmondchuc

Copy link
Copy Markdown
Contributor Author

Fine to squash merge, thanks.

Add one-based member selection through geof:geometryN, retaining the selected member's datatype, SRS and layout. Accept only xsd:integer indexes, including integer-derived types such as xsd:short. Round-trip empty members in homogeneous WKT Multi geometries, including empty aggregates whose Z/M/ZM marker differs from the enclosing collection, and empty GML polygons whose CRS is 3D.
Put WKT and GML regression tests in their reader and writer test classes, and move dimension and geometry selection tests into their existing test classes. Preserve the coordinate layout of all-empty GML Surface patches.
@edmondchuc
edmondchuc force-pushed the feat/geosparql/geometry-n-function branch from 1553c96 to 92a34e2 Compare September 27, 2026 01:51
@edmondchuc

Copy link
Copy Markdown
Contributor Author

@afs merge conflicts resolved.

@afs
afs merged commit a0f5aa1 into apache:main Sep 27, 2026
1 check passed
@edmondchuc
edmondchuc deleted the feat/geosparql/geometry-n-function branch September 27, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GeoSPARQL 1.1 geof:geometryN function

2 participants