furqaankhan commented on code in PR #1038:
URL: https://github.com/apache/sedona/pull/1038#discussion_r1339420740


##########
common/src/main/java/org/apache/sedona/common/raster/RasterEditors.java:
##########
@@ -97,4 +106,133 @@ public static GridCoverage2D 
setGeoReference(GridCoverage2D raster, double upper
         String geoRedCoord = String.format("%f %f %f %f %f %f", scaleX, skewY, 
skewX, scaleY, upperLeftX, upperLeftY);
         return setGeoReference(raster, geoRedCoord, "GDAL");
     }
+
+    public static GridCoverage2D resample(GridCoverage2D raster, double 
widthOrScale, double heightOrScale, double gridX, double gridY, boolean 
useScale,String algorithm) throws TransformException {
+        /*
+        * Old Parameters
+        */
+        AffineTransform2D affine = RasterUtils.getGDALAffineTransform(raster);
+        int originalWidth = RasterAccessors.getWidth(raster), originalHeight = 
RasterAccessors.getHeight(raster);
+        double upperLeftX = affine.getTranslateX(), upperLeftY = 
affine.getTranslateY();
+        double originalSkewX = affine.getShearX(), originalSkewY = 
affine.getShearY();
+        double originalScaleX = affine.getScaleX(), originalScaleY = 
affine.getScaleY();
+        CoordinateReferenceSystem crs = 
raster.getCoordinateReferenceSystem2D();
+
+        /*
+         * New Parameters
+         */
+        int newWidth = useScale ? originalWidth : 
(int)Math.floor(widthOrScale);
+        int newHeight = useScale ? originalHeight : 
(int)Math.floor(heightOrScale);
+        double newScaleX = useScale ? widthOrScale : originalScaleX;
+        double newScaleY = useScale ? heightOrScale : originalScaleY;
+        double newUpperLeftX = upperLeftX, newUpperLeftY = upperLeftY;
+
+        if (noConfigChange(originalWidth, originalHeight, upperLeftX, 
upperLeftY, originalScaleX, originalScaleY, newWidth, newHeight, gridX, gridY, 
newScaleX, newScaleY, useScale)) {
+            // no reconfiguration parameters provided
+            return raster;
+        }
+
+
+        Envelope2D envelope2D = raster.getEnvelope2D();
+        //process scale changes due to changes in widthOrScale and 
heightOrScale
+        if (!useScale) {
+            newScaleX = (Math.abs(envelope2D.getMaxX() - 
envelope2D.getMinX())) / newWidth;
+            newScaleY = Math.signum(originalScaleY) * 
Math.abs(envelope2D.getMaxY() - envelope2D.getMinY()) / newHeight;
+//            newScaleX *= ((double) originalWidth / );
+//            newScaleY *= ((double) originalHeight / 
Math.floor(heightOrScale));

Review Comment:
   Same with this. Please remove if not needed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to