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-347] Centralize transform() usages #949

Merged
merged 44 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c6f7eae
Add RS_Height and RS_Width
iGN5117 Jul 27, 2023
42bf79c
Merge branch 'sedona-master' into develop_Nilesh_Rasters
iGN5117 Jul 27, 2023
66fc4e9
Remove unused imports
iGN5117 Jul 28, 2023
7eec81a
Add ScaleX and ScaleY
iGN5117 Jul 28, 2023
5e0ebe3
Merge branch 'sedona-master' into develop_Nilesh_Rasters
iGN5117 Jul 28, 2023
39c9ee0
Removed version control markers
iGN5117 Jul 28, 2023
50e56b1
Address PR comments
iGN5117 Jul 28, 2023
2710f63
Add RS_PixelAsPoint
iGN5117 Jul 28, 2023
2c490d5
Merge branch 'sedona-master' into develop_Nilesh_Rasters
iGN5117 Jul 28, 2023
4a9136b
Add helper function to read geoTiff file from filesystem in raster ja…
iGN5117 Jul 29, 2023
1109dae
Added more tests for pixelAsPoint
iGN5117 Jul 31, 2023
e2c5366
optimized imports
iGN5117 Jul 31, 2023
10ecc74
Change raster constructor logic to make use of created Affine Transfo…
iGN5117 Aug 1, 2023
49fcfd6
Make sure returned Geometry has same SRID as the raster
iGN5117 Aug 1, 2023
25b5b88
Add additonal tests testing different SRIDs
iGN5117 Aug 1, 2023
9e59c73
Reverted accidental skew changes
iGN5117 Aug 1, 2023
9bd3d13
Remove unused gridGeometry in RasterConstructor
iGN5117 Aug 1, 2023
e1c387a
Revert raster constructor changes
iGN5117 Aug 2, 2023
856f85b
removed unused import
iGN5117 Aug 2, 2023
2feb4ce
Merge branch 'sedona-master' into develop_Nilesh_Rasters
iGN5117 Aug 2, 2023
b4c4b99
Merge branch 'sedona-master' into develop_Nilesh_Rasters
iGN5117 Aug 2, 2023
96d5175
Update PixelAsPoint documentation to mention 1-indexed grid coordinates
iGN5117 Aug 2, 2023
ff36849
Refactor PixelAsPoint to keep grid coordinates 1-indexed.
iGN5117 Aug 2, 2023
e37d7f8
Refactor PixelAsPoint tests
iGN5117 Aug 2, 2023
4d45e1c
Add test for reading raster from raster file
iGN5117 Aug 2, 2023
0557edd
Fixed failing scala test case
iGN5117 Aug 2, 2023
27341b2
Add RS_Contains and RS_Within
iGN5117 Aug 4, 2023
56f1500
Optimized imports
iGN5117 Aug 4, 2023
dd4538e
Merge branch 'sedona-master' into develop_Nilesh_Rasters
iGN5117 Aug 4, 2023
97c5cc9
Refactored PixelAsPoint to use common functions
iGN5117 Aug 4, 2023
f7d8c25
Add utility function for getting corner coordinate with range check
iGN5117 Aug 4, 2023
647f27d
Fix utility function
iGN5117 Aug 4, 2023
2e701cb
Add RS_RasterToWorldCoordX and Y
iGN5117 Aug 4, 2023
bf15b10
Merge branch 'master' into develop_Nilesh_Rasters
iGN5117 Aug 7, 2023
02eecd8
Add WorldToRasterCoord, WorldToRasterCoordX, WorldToRasterCoordY
iGN5117 Aug 8, 2023
ea0f9e4
Merge branch 'sedona-master' into develop_Nilesh_Rasters
iGN5117 Aug 8, 2023
7f56bbe
Add an overloaded flavor of transform that takes only 1 CRS string
iGN5117 Aug 8, 2023
77fee52
Merge branch 'develop_Nilesh_Rasters' into develop_Nilesh_Raster_Pred…
iGN5117 Aug 8, 2023
3daecbc
Centralize usages of transform()
iGN5117 Aug 8, 2023
af63c69
Move tranform() function to geomUtils to prevent inference confusion
iGN5117 Aug 8, 2023
6e961df
refactor import
iGN5117 Aug 8, 2023
461d94a
change parameter name from lon and lat to x and y respectively
iGN5117 Aug 8, 2023
be136c9
Merge branch 'develop_Nilesh_Rasters' into develop_Nilesh_Raster_Pred…
iGN5117 Aug 8, 2023
597a5b0
Merge branch 'master' into develop_Nilesh_Raster_Predicates
jiayuasu Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ public static Geometry transform(Geometry geometry, String sourceCRS, String tar
return transform(geometry, sourceCRS, targetCRS, false);
}


public static Geometry transform(Geometry geometry, String sourceCRS, String targetCRS, boolean lenient)
throws FactoryException, TransformException {

CoordinateReferenceSystem sourceCRScode = parseCRSString(sourceCRS);
CoordinateReferenceSystem sourceCRSCode = parseCRSString(sourceCRS);
CoordinateReferenceSystem targetCRScode = parseCRSString(targetCRS);
MathTransform transform = CRS.findMathTransform(sourceCRScode, targetCRScode, lenient);
return JTS.transform(geometry, transform);
return GeomUtils.transform(geometry, sourceCRSCode, targetCRScode, lenient);
}


private static CoordinateReferenceSystem parseCRSString(String CRSString)
throws FactoryException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
package org.apache.sedona.common.utils;

import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.*;
import org.locationtech.jts.geom.impl.CoordinateArraySequence;
import org.locationtech.jts.io.ByteOrderValues;
Expand All @@ -23,6 +25,10 @@
import org.locationtech.jts.algorithm.Angle;
import org.locationtech.jts.algorithm.distance.DiscreteFrechetDistance;
import org.locationtech.jts.algorithm.distance.DiscreteHausdorffDistance;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;

import java.nio.ByteOrder;
import java.util.*;
Expand Down Expand Up @@ -242,6 +248,11 @@ public static Geometry buildArea(Geometry geom) {
return outputGeom;
}

public static Geometry transform(Geometry geometry, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient) throws FactoryException, TransformException {
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, lenient);
return JTS.transform(geometry, transform);
}

public static int getDimension(Geometry geometry) {
return geometry.getCoordinate() != null && !java.lang.Double.isNaN(geometry.getCoordinate().getZ()) ? 3 : 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.sedona.common.utils;

import com.sun.media.imageioimpl.common.BogusColorSpace;
import org.apache.sedona.common.Functions;
import org.geotools.coverage.CoverageFactoryFinder;
import org.geotools.coverage.GridSampleDimension;
import org.geotools.coverage.grid.GridCoordinates2D;
Expand Down Expand Up @@ -132,8 +133,7 @@ public static Geometry convertCRSIfNeeded(Geometry geometry, CoordinateReference
try {
CoordinateReferenceSystem queryWindowCRS = CRS.decode("EPSG:" + geomSRID);
if (!CRS.equalsIgnoreMetadata(rasterCRS, queryWindowCRS)) {
MathTransform transform = CRS.findMathTransform(queryWindowCRS, rasterCRS, true);
geometry = JTS.transform(geometry, transform);
geometry = GeomUtils.transform(geometry, queryWindowCRS, rasterCRS, true);
}
} catch (FactoryException | TransformException e) {
throw new RuntimeException("Cannot transform CRS of query window", e);
Expand Down
Loading