Revision: 6184
          http://sourceforge.net/p/jump-pilot/code/6184
Author:   ma15569
Date:     2019-04-17 16:00:48 +0000 (Wed, 17 Apr 2019)
Log Message:
-----------
- Added Boolean to verify if a <RasterImageLayer> rLayer1 is spatially 
equivalent to another <RasterImageLayer> rLayer2
- Corrected deprecated methods

Modified Paths:
--------------
    core/trunk/src/org/openjump/core/ui/util/LayerableUtil.java

Modified: core/trunk/src/org/openjump/core/ui/util/LayerableUtil.java
===================================================================
--- core/trunk/src/org/openjump/core/ui/util/LayerableUtil.java 2019-04-17 
04:39:29 UTC (rev 6183)
+++ core/trunk/src/org/openjump/core/ui/util/LayerableUtil.java 2019-04-17 
16:00:48 UTC (rev 6184)
@@ -1,5 +1,6 @@
 package org.openjump.core.ui.util;
 
+import java.awt.image.Raster;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -55,6 +56,42 @@
      */
 
     /**
+     * Boolean to verify if a <RasterImageLayer> rLayer1 is spatially 
equivalent to another <RasterImageLayer> rLayer2
+     * @param RasterImageLayer layer
+     * @return True if they are equivalent. False if they are not equivalent
+     * @throws IOException
+     */
+
+    public static boolean isSpatiallyEqualTo(RasterImageLayer rLayer1,
+            RasterImageLayer rLayer2) throws IOException {
+
+        boolean isEqual = true;
+        final Raster raster1 = rLayer1.getRasterData(null);
+        final Raster raster2 = rLayer2.getRasterData(null);
+        if (raster1.getHeight() != raster2.getHeight()) {
+            isEqual = false;
+        }
+        if (raster1.getWidth() != raster2.getWidth()) {
+            isEqual = false;
+        }
+        if (rLayer1.getMetadata().getActualLowerLeftCoord() != rLayer2
+                .getMetadata().getActualLowerLeftCoord()) {
+            isEqual = false;
+
+        }
+        if (rLayer1.getMetadata().getActualCellSize() != rLayer2.getMetadata()
+                .getActualCellSize()) {
+            isEqual = false;
+        }
+        if (rLayer1.getNoDataValue() != rLayer2.getNoDataValue()) {
+            isEqual = false;
+        }
+
+        return isEqual;
+
+    }
+
+    /**
      * RasterImageLayer.class
      * 
      * @return true if selected sextante raster (RasterImageLayer.class) is
@@ -863,7 +900,8 @@
         outPRJ = context.getLayerManager().uniqueLayerName(
                 layer.getName() + ".prj");
         outFile = new File(path.concat(File.separator).concat(outPRJ));
-        FileUtils.writeStringToFile(outFile, proj);
+        // FileUtils .writeStringToFile(outFile, proj);//Deprecated
+        FileUtils.writeStringToFile(outFile, proj, charSet);
     }
 
     /**
@@ -885,9 +923,12 @@
         outPRJ = context.getLayerManager().uniqueLayerName(
                 layer.getName() + ".prj");
         outFile = new File(path.concat(File.separator).concat(outPRJ));
-        FileUtils.writeStringToFile(outFile, proj);
+        // FileUtils .writeStringToFile(outFile, proj);//Deprecated
+        FileUtils.writeStringToFile(outFile, proj, charSet);
     }
 
+    final static String charSet = "UTF-8";
+
     /**
      * Simple method to copy a file (as worldfile)
      */



_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to