Skip to content

Conversation

@umartin
Copy link
Contributor

@umartin umartin commented Aug 20, 2025

Description

Allow converting geometries, and not only spherical geographies, to GeoJSON

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

## General
* Add support for `Geometry` type in {func}`to_geojson_geometry`. ({issue}`26451`)

@cla-bot cla-bot bot added the cla-signed label Aug 20, 2025
@wendigo wendigo requested a review from martint August 22, 2025 08:27
{
return new GeoJsonWriter().write(geometry);
GeoJsonWriter geoJsonWriter = new GeoJsonWriter();
geoJsonWriter.setEncodeCRS(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to a separate commit to keep logically independent changes separate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done
#26499

@Description("Returns GeoJSON string based on the input spherical geography")
@SqlType(VARCHAR)
public static Slice toGeoJsonGeometry(@SqlType(StandardTypes.SPHERICAL_GEOGRAPHY) Slice input)
public static Slice toGeoJsonGeometryFromGeography(@SqlType(StandardTypes.SPHERICAL_GEOGRAPHY) Slice input)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename the method to geographyToGeoJson

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's much better. Thank you.
Done

@ScalarFunction("to_geojson_geometry")
@Description("Returns GeoJSON string based on the input geometry")
@SqlType(VARCHAR)
public static Slice toGeoJsonGeometryFromGeometry(@SqlType(StandardTypes.GEOMETRY) Slice input)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, rename this one to geometryToGeoJson

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

assertGeometryToAndFromJson("LINESTRING (0 0, 1 1, 1 0, 0 1)");
}

private void assertGeometryToAndFromJson(String wkt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename the other method (assertGeoToAndFromJson) to assertGeographyToAndFromJson to avoid confusion with this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@umartin umartin force-pushed the to_geojson_geometry branch from ad9e3f2 to 55f5716 Compare August 27, 2025 10:05
@martint martint merged commit 515c8c0 into trinodb:master Sep 4, 2025
21 checks passed
@github-actions github-actions bot added this to the 477 milestone Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants