Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SEDONA-343] Add RS_Contains and RS_Within #946

Merged
merged 2 commits into from
Aug 5, 2023

Conversation

iGN5117
Copy link
Contributor

@iGN5117 iGN5117 commented Aug 4, 2023

Did you read the Contributor Guide?

Is this PR related to a JIRA ticket?

What changes were proposed in this PR?

  • Add RS_Contains
  • Add RS_Within

How was this patch tested?

  • Added new tests

Did this PR include necessary documentation updates?

return rasterGeometry.within(geometry);
}

private static Geometry convertCRSIfNeeded(Geometry geometry, CoordinateReferenceSystem rasterCRS) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you re-use the code of ST_Transform?

Copy link
Member

Choose a reason for hiding this comment

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

Is the order lon/lat or lat/lon?


private static Geometry convertCRSIfNeeded(Geometry geometry, CoordinateReferenceSystem rasterCRS) {
int geomSRID = geometry.getSRID();
if (rasterCRS != null && !(rasterCRS instanceof DefaultEngineeringCRS) && geomSRID > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Is the DefaultEngineeringCRS default or DefaultCartisian2D?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DefaultEngineeringCRS is the default CRS, as also mentioned in makeEmptyRaster()

GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
Geometry geometry = geometryFactory.toGeometry(new Envelope(30, 60, 10, 50));
GridCoverage2D raster = RasterConstructors.makeEmptyRaster(1, 20, 20, 32, 35, 1, -1, 0, 0, 4326);
geometry = JTS.transform(geometry, CRS.findMathTransform(raster.getCoordinateReferenceSystem(), CRS.decode("EPSG:3857")));
Copy link
Member

Choose a reason for hiding this comment

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

Try to re-use the code from ST_Transform

@jiayuasu jiayuasu merged commit 2a5fe3e into apache:master Aug 5, 2023
41 checks passed
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.

None yet

2 participants