Revision: 5565
          http://sourceforge.net/p/jump-pilot/code/5565
Author:   ma15569
Date:     2017-11-14 10:47:59 +0000 (Tue, 14 Nov 2017)
Log Message:
-----------
Moved all srid detection (included temp files) to ProjUtils.class

Modified Paths:
--------------
    core/trunk/src/org/openjump/core/ccordsys/utils/ProjUtils.java
    core/trunk/src/org/openjump/core/ccordsys/utils/SRSInfo.java
    core/trunk/src/org/openjump/core/rasterimage/AddRasterImageLayerWizard.java
    
core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java

Modified: core/trunk/src/org/openjump/core/ccordsys/utils/ProjUtils.java
===================================================================
--- core/trunk/src/org/openjump/core/ccordsys/utils/ProjUtils.java      
2017-11-13 21:48:13 UTC (rev 5564)
+++ core/trunk/src/org/openjump/core/ccordsys/utils/ProjUtils.java      
2017-11-14 10:47:59 UTC (rev 5565)
@@ -1,16 +1,12 @@
 package org.openjump.core.ccordsys.utils;
 
-import com.vividsolutions.jump.I18N;
-import com.vividsolutions.jump.feature.Feature;
-import com.vividsolutions.jump.feature.FeatureCollection;
-import com.vividsolutions.jump.io.datasource.DataSource;
-import com.vividsolutions.jump.io.datasource.DataSourceQuery;
-import com.vividsolutions.jump.util.FileUtil;
-import com.vividsolutions.jump.workbench.JUMPWorkbenchContext;
-import com.vividsolutions.jump.workbench.imagery.ImageryLayerDataset;
-import com.vividsolutions.jump.workbench.imagery.ReferencedImageStyle;
-import com.vividsolutions.jump.workbench.model.Layer;
-import 
com.vividsolutions.jump.workbench.ui.plugin.datastore.DataStoreQueryDataSource;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Scanner;
 
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.io.FilenameUtils;
@@ -21,24 +17,24 @@
 import org.openjump.core.ccordsys.srid.SRIDStyle;
 import org.openjump.core.rasterimage.RasterImageLayer;
 import org.openjump.core.rasterimage.TiffTags;
-
-
-
 import org.openjump.core.rasterimage.TiffTags.TiffReadingException;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Scanner;
+import com.vividsolutions.jump.I18N;
+import com.vividsolutions.jump.feature.Feature;
+import com.vividsolutions.jump.feature.FeatureCollection;
+import com.vividsolutions.jump.io.datasource.DataSource;
+import com.vividsolutions.jump.io.datasource.DataSourceQuery;
+import com.vividsolutions.jump.util.FileUtil;
+import com.vividsolutions.jump.workbench.imagery.ImageryLayerDataset;
+import com.vividsolutions.jump.workbench.imagery.ReferencedImageStyle;
+import com.vividsolutions.jump.workbench.model.Layer;
+import 
com.vividsolutions.jump.workbench.ui.plugin.datastore.DataStoreQueryDataSource;
 
 /**
- * Giuseppe Aruta [23_3_2016] This class is used to recognize file
- * projection. There are different methods A) a method to decode projection
- * information from GeoTIFF metadata. B) a method to decode projection info
- * from auxiliary files (.proj and .aux.xml).
+ * Giuseppe Aruta [23_3_2016] This class is used to recognize file projection.
+ * There are different methods A) a method to decode projection information 
from
+ * GeoTIFF metadata. B) a method to decode projection info from auxiliary files
+ * (.proj and .aux.xml).
  * http://landsathandbook.gsfc.nasa.gov/pdfs/geotiff_spec.pdf
  * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/GeoTiff.html
  * http://www.remotesensing.org/geotiff/spec/geotiff6.html
@@ -55,13 +51,13 @@
             
.get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.User_defined");
     private static final String NOT_RECOGNIZED = I18N
             
.get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.Not_recognized");
-    private static final String NO_SRS =I18N
-        .get("org.openjump.core.ccordsys.No-srs");
-    private static final String EMBEDDED_SRS =I18N
-        .get("org.openjump.core.ccordsys.Embedded-srs");    
-    private static final String NOT_CONSISTENT_SRS =I18N
-        .get("org.openjump.core.ccordsys.Not-consistent-srs");       
-   
+    private static final String NO_SRS = I18N
+            .get("org.openjump.core.ccordsys.No-srs");
+    private static final String EMBEDDED_SRS = I18N
+            .get("org.openjump.core.ccordsys.Embedded-srs");
+    private static final String NOT_CONSISTENT_SRS = I18N
+            .get("org.openjump.core.ccordsys.Not-consistent-srs");
+
     /**
      * - Read SRS from GeoTIFF tag - This method gets projection srid code and
      * projection info from a geotiff file. It first scans GeoKeyDirectoryTag 
to
@@ -78,11 +74,11 @@
      */
     @SuppressWarnings("static-access")
     public static SRSInfo getSRSInfoFromGeoTiff(String fileSourcePath)
-            throws IOException, URISyntaxException, 
TiffTags.TiffReadingException, ImageReadException {
+            throws IOException, URISyntaxException,
+            TiffTags.TiffReadingException, ImageReadException {
         return TiffTags.readMetadata(new File(fileSourcePath)).getSRSInfo();
     }
 
-
     /**
      * - Read SRS from auxiliary file - Method to get a SRS (SRID code + SRID
      * definition) scanning the aux projection file (AUX.XML or PRJ file) for a
@@ -93,7 +89,8 @@
      * strings like "NAD83 UTM zone 10N" or "26910" both return
      * "SRID:26910 - NAD83 UTM zone 10N".
      *
-     * @param fileSourcePath auxiliary file path
+     * @param fileSourcePath
+     *            auxiliary file path
      * @return SRSInfo and Projection definition
      * @throws URISyntaxException
      * @throws IOException
@@ -123,17 +120,19 @@
                 scanner.close();
                 try {
                     // Use new crs library to parse prj file if possible
-                    CoordinateReferenceSystem crs = new 
CRSFactory().createFromPrj(textProj);
-                    if (crs.getAuthorityKey() != null && 
!crs.getAuthorityKey().equals("0")) {
+                    CoordinateReferenceSystem crs = new CRSFactory()
+                            .createFromPrj(textProj);
+                    if (crs.getAuthorityKey() != null
+                            && !crs.getAuthorityKey().equals("0")) {
                         srsInfo.setRegistry(crs.getAuthorityName());
                         srsInfo.setCode(crs.getAuthorityKey());
-                        
srsInfo.setUnit(Unit.find(crs.getCoordinateSystem().getUnit(0).toString()));
+                        srsInfo.setUnit(Unit.find(crs.getCoordinateSystem()
+                                .getUnit(0).toString()));
                         srsInfo.setDescription(crs.getName());
                         srsInfo.complete();
                         return srsInfo;
                     }
-                }
-                catch(CRSException e) {
+                } catch (CRSException e) {
                     e.printStackTrace();
                 }
             }
@@ -158,11 +157,11 @@
         return srsInfo;
     }
 
-
     /**
      * Method to show an OGC WKT string in a more readable style
      *
-     * @param WKT OGC WKT from auxiliary proj file
+     * @param WKT
+     *            OGC WKT from auxiliary proj file
      * @return Readable string
      */
     public static String readableFormatWKTCode(String WKT) {
@@ -178,8 +177,8 @@
 
     /**
      * Decode a OGC string to get a unique SRS string definition. This method 
is
-     * able to understand some WKT common aliases, like OGC WKT and ESRI 
WKTCode.
-     * For instance: "WGS 84 / UTM zone 32", "WGS 1984 UTM zone 32" and
+     * able to understand some WKT common aliases, like OGC WKT and ESRI
+     * WKTCode. For instance: "WGS 84 / UTM zone 32", "WGS 1984 UTM zone 32" 
and
      * "WGS_84_UTM_Zone_32" are converted to the same string
      * "WGS 84 UTM zone 32"
      *
@@ -255,38 +254,40 @@
     }
 
     /**
-     * Method to get SRID from a layer from Style or from auxiliary file. 
-     * It tries to check all possibilities:
-     * a) SRID is recorded from layer auxiliary file
-     * b) SRID is recorded from data source
-     * c) No SRID is available
-     * d) Layer SRID doesn't match auxilary file/datasource SRID
+     * Method to get SRID from a layer from Style or from auxiliary file. It
+     * tries to check all possibilities: a) SRID is recorded from layer
+     * auxiliary file b) SRID is recorded from data source c) No SRID is
+     * available d) Layer SRID doesn't match auxilary file/datasource SRID
+     * 
      * @param layer
      * @return SRID
      * @throws Exception
-     */   
-    
+     */
+
     public static SRSInfo getSRSInfoFromLayerStyleOrSource(Layer layer)
-        throws Exception {
-    // read SRID layer recorded as STYLE (for WFS, Databases and newly
-    // generated files)
+            throws Exception {
+        // read SRID layer recorded as STYLE (for WFS, Databases and newly
+        // generated files)
         SRIDStyle sridStyle = (SRIDStyle) layer.getStyle(SRIDStyle.class);
         int SRID_style_int = sridStyle.getSRID();
         String SRID_style_string = String.valueOf(SRID_style_int);
-    // read SRID layer from aux file or geotiff tag
-       SRSInfo srsInfo = ProjUtils.getSRSInfoFromLayerSource(layer);
-       String SRID_srs_string = srsInfo.getCode();
-       srsInfo.setCode(SRID_style_string);
-       if (SRID_srs_string.equals("0") & SRID_style_string.equals("0") & 
!isTemporaryLayer(layer))
-           srsInfo.setSource(NO_SRS);
-       if ((!SRID_style_string.equals(SRID_srs_string) & 
SRID_srs_string.equals("0") & !SRID_style_string.equals("0")) & 
!isTemporaryLayer(layer) || isImageGeoTIFFLayer(layer) ) 
-           srsInfo.setSource(EMBEDDED_SRS);
-      if (!SRID_style_string.equals(SRID_srs_string) & 
!SRID_style_string.equals("0") & !SRID_srs_string.equals("0"))
-           srsInfo.setSource(NOT_CONSISTENT_SRS);
+        // read SRID layer from aux file or geotiff tag
+        SRSInfo srsInfo = ProjUtils.getSRSInfoFromLayerSource(layer);
+        String SRID_srs_string = srsInfo.getCode();
+        srsInfo.setCode(SRID_style_string);
+        if (SRID_srs_string.equals("0") & SRID_style_string.equals("0")
+                & !isTemporaryLayer(layer))
+            srsInfo.setSource(NO_SRS);
+        if ((!SRID_style_string.equals(SRID_srs_string)
+                & SRID_srs_string.equals("0") & !SRID_style_string.equals("0"))
+                & !isTemporaryLayer(layer) || isImageGeoTIFFLayer(layer))
+            srsInfo.setSource(EMBEDDED_SRS);
+        if (!SRID_style_string.equals(SRID_srs_string)
+                & !SRID_style_string.equals("0") & 
!SRID_srs_string.equals("0"))
+            srsInfo.setSource(NOT_CONSISTENT_SRS);
         srsInfo.complete();
         return srsInfo;
     }
-    
 
     /**
      * Method to get SRID from a layer from Style or from auxiliary file. First
@@ -297,10 +298,12 @@
      * @return SRID
      * @throws Exception
      */
-    public static SRSInfo getSRSInfoFromLayerStyleOrSource_old(Layer layer) 
throws Exception {
+    public static SRSInfo getSRSInfoFromLayerStyleOrSource_old(Layer layer)
+            throws Exception {
         SRSInfo srsInfo = new SRSInfo();
 
-        // First we check if a SRID != 0 has already been recorded for this 
Layer
+        // First we check if a SRID != 0 has already been recorded for this
+        // Layer
         SRIDStyle sridStyle = (SRIDStyle) layer.getStyle(SRIDStyle.class);
         final int oldSRID = sridStyle.getSRID();
         if (oldSRID > 0) {
@@ -315,7 +318,7 @@
         return srsInfo;
 
     }
-    
+
     /**
      * Method to get SRID from a layer file from auxiliary files (.prj or .aux)
      * or GeoTIFFed tag. If the auxiliary file SRID does not exist, it returns
@@ -325,7 +328,8 @@
      * @return SRID
      * @throws Exception
      */
-    public static SRSInfo getSRSInfoFromLayerSource(Layer layer) throws 
Exception {
+    public static SRSInfo getSRSInfoFromLayerSource(Layer layer)
+            throws Exception {
         String fileSourcePath = "";
         SRSInfo srsInfo = new SRSInfo();
         // Raster layer case
@@ -333,11 +337,11 @@
             FeatureCollection featureCollection = layer
                     .getFeatureCollectionWrapper();
             String sourcePathImage = null;
-            
+
             for (Iterator i = featureCollection.iterator(); i.hasNext();) {
                 Feature feature = (Feature) i.next();
                 sourcePathImage = feature
-                      .getString(ImageryLayerDataset.ATTR_URI);
+                        .getString(ImageryLayerDataset.ATTR_URI);
 
                 if (sourcePathImage != null && !sourcePathImage.isEmpty()) {
                     File f = new File(URI.create(sourcePathImage).getPath());
@@ -348,10 +352,12 @@
                 }
             }
 
-            String extension = 
FileUtil.getExtension(fileSourcePath).toUpperCase();
+            String extension = FileUtil.getExtension(fileSourcePath)
+                    .toUpperCase();
             if ((extension.equals("TIF") || extension.equals("TIFF"))) {
                 // If TIFF file is a geotiff, it scans into embedded tag
-                TiffTags.TiffMetadata metadata = TiffTags.readMetadata(new 
File(fileSourcePath));
+                TiffTags.TiffMetadata metadata = TiffTags
+                        .readMetadata(new File(fileSourcePath));
                 if (metadata.isGeoTiff()) {
                     srsInfo = metadata.getSRSInfo();
                     // If the TIF file is not a GeoTIFF it looks
@@ -369,10 +375,12 @@
                 DataSourceQuery dsq = layer.getDataSourceQuery();
                 Map properties = dsq.getDataSource().getProperties();
                 if (properties.get(DataSource.URI_KEY) != null) {
-                    fileSourcePath = new 
URI(properties.get(DataSource.URI_KEY).toString()).getPath();
+                    fileSourcePath = new URI(properties.get(DataSource.URI_KEY)
+                            .toString()).getPath();
                     srsInfo = getSRSInfoFromAuxiliaryFile(fileSourcePath);
                 } else if (properties.get(DataSource.FILE_KEY) != null) {
-                    fileSourcePath = 
properties.get(DataSource.FILE_KEY).toString();
+                    fileSourcePath = properties.get(DataSource.FILE_KEY)
+                            .toString();
                     srsInfo = getSRSInfoFromAuxiliaryFile(fileSourcePath);
                 }
             }
@@ -390,24 +398,23 @@
         }
     }
 
-    //Boolean, Select layer is a temporary layer
-    private static boolean isTemporaryLayer(Layer layer){
-      DataSourceQuery dsq = layer.getDataSourceQuery();
-      String sclass = layer.getClass().getSimpleName();
-      if (dsq == null && layer.getStyle(ReferencedImageStyle.class) == null
-                    && layer.getDescription() != null && 
!sclass.equals("WFSLayer"))
-    {
-       return true;
-     } else {
-       return false;
-   }
-}
-    
-    
+    // Boolean, Select layer is a temporary layer
+    private static boolean isTemporaryLayer(Layer layer) {
+        DataSourceQuery dsq = layer.getDataSourceQuery();
+        String sclass = layer.getClass().getSimpleName();
+        if (dsq == null && layer.getStyle(ReferencedImageStyle.class) == null
+                && layer.getDescription() != null && 
!sclass.equals("WFSLayer")) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
     // Boolean. Selected layer is related to a database
     private static boolean isDataBaseLayer(Layer layer) {
         DataSourceQuery dsq = layer.getDataSourceQuery();
-        if (dsq == null || dsq.getDataSource() instanceof 
DataStoreQueryDataSource) {
+        if (dsq == null
+                || dsq.getDataSource() instanceof DataStoreQueryDataSource) {
             return true;
         } else {
             return false;
@@ -414,7 +421,6 @@
         }
     }
 
-    
     // Boolean. Selected layer is related to GEoTIFF file
     public static boolean isImageGeoTIFFLayer(Layer layer) {
         // String sclass = layer.getClass().getSimpleName();
@@ -439,48 +445,60 @@
                     }
                 }
             }
-            String extension = 
FileUtil.getExtension(fileSourcePath).toUpperCase();
+            String extension = FileUtil.getExtension(fileSourcePath)
+                    .toUpperCase();
             if ((extension.equals("TIF") || extension.equals("TIFF"))) {
-            TiffTags.TiffMetadata metadata = null;
-            try {
-                metadata = TiffTags.readMetadata(new File(fileSourcePath));
-            } catch (ImageReadException | IOException | TiffReadingException 
e) {
-                e.printStackTrace();
+                TiffTags.TiffMetadata metadata = null;
+                try {
+                    metadata = TiffTags.readMetadata(new File(fileSourcePath));
+                } catch (ImageReadException | IOException
+                        | TiffReadingException e) {
+                    e.printStackTrace();
+                }
+                if (metadata.isGeoTiff()) {
+                    return true;
+                } else {
+                    return false;
+                }
             }
+        }
+        return false;
+    }
+
+    // [Giuseppe Aruta 04/01/2017] get SRS info for RasterImageLayer.class
+    // [Giuseppe Aruta 14/11/2017] First it checks if selected raster is
+    // a GeoTIFF and scan tiff tags for projection.
+    // If selected file is not a GeoTIF, it checks if <Filename>.AUX.XML exists
+    // and scans inside it.
+    // If no <Filename>.AUX.XML if found then it scans into <filename>.PRJ file
+    // If layer is temporary or srid=0, it sets srid source to null
+    //
+    public static SRSInfo getSRSInfoFromLayerSource(RasterImageLayer layer)
+            throws Exception, URISyntaxException {
+        String fileSourcePath = layer.getImageFileName();
+        String extension = FileUtil.getExtension(fileSourcePath).toLowerCase();
+        SRSInfo srsInfo;
+        if (extension.equals("tif") || extension.equals("tiff")) {
+            TiffTags.TiffMetadata metadata = TiffTags.readMetadata(new File(
+                    fileSourcePath));
             if (metadata.isGeoTiff()) {
-                return true;
+                srsInfo = metadata.getSRSInfo();
+                srsInfo.setSource(EMBEDDED_SRS);
             } else {
-                return false;
+                srsInfo = 
ProjUtils.getSRSInfoFromAuxiliaryFile(fileSourcePath);
             }
-        }
-       }
-      return false;
-    }
-    
-    
-    //[Giuseppe Aruta 04/01/2017] get SRS info for RasterImageLayer.class
-    public static SRSInfo getSRSInfoFromLayerSource(RasterImageLayer layer)
-        throws Exception, URISyntaxException {
-    String fileSourcePath = layer.getImageFileName();
-    String extension = FileUtil.getExtension(fileSourcePath).toLowerCase();
-    SRSInfo srsInfo;
-    if (extension.equals("tif") || extension.equals("tiff")) {
-        TiffTags.TiffMetadata metadata = TiffTags.readMetadata(new File(
-                fileSourcePath));
-        if (metadata.isGeoTiff()) {
-
-            srsInfo = metadata.getSRSInfo();
         } else {
             srsInfo = ProjUtils.getSRSInfoFromAuxiliaryFile(fileSourcePath);
-
         }
-    } else {
-        srsInfo = ProjUtils.getSRSInfoFromAuxiliaryFile(fileSourcePath);
+        // if srid=0 there must be no source for file projection.
+        // if the layer is temporary (file saved into TEMP folder), srid source
+        // is kept to null
+        // to avoid to save projection as an aux file for this layer
+        if (srsInfo.getCode().equals("0") || layer.isTemporaryLayer()) {
+            srsInfo.setSource("null");
+        }
+        srsInfo.complete();
+        return srsInfo;
+    }
 
-    }
-    return srsInfo;
-    // Integer.parseInt(srsInfo.getCode());
 }
-    
-}
-

Modified: core/trunk/src/org/openjump/core/ccordsys/utils/SRSInfo.java
===================================================================
--- core/trunk/src/org/openjump/core/ccordsys/utils/SRSInfo.java        
2017-11-13 21:48:13 UTC (rev 5564)
+++ core/trunk/src/org/openjump/core/ccordsys/utils/SRSInfo.java        
2017-11-14 10:47:59 UTC (rev 5565)
@@ -1,17 +1,17 @@
 package org.openjump.core.ccordsys.utils;
 
-import org.openjump.core.ccordsys.Unit;
-
-import java.io.UnsupportedEncodingException;
-
 import static org.openjump.core.ccordsys.utils.SRSInfo.Registry.EPSG;
 import static org.openjump.core.ccordsys.utils.SRSInfo.Registry.ESRI;
 import static org.openjump.core.ccordsys.utils.SRSInfo.Registry.SRID;
 
+import java.io.UnsupportedEncodingException;
+
+import org.openjump.core.ccordsys.Unit;
+
 /**
- * Small container for SRS information.
- * This class does not contain all information to perform coordinate 
transformation,
- * but enough to return metadata about SRS code or map unit
+ * Small container for SRS information. This class does not contain all
+ * information to perform coordinate transformation, but enough to return
+ * metadata about SRS code or map unit
  */
 public class SRSInfo {
 
@@ -18,15 +18,20 @@
     public static final String UNDEFINED = "0";
     public static final String USERDEFINED = "USER-DEFINED";
 
-    public enum Registry{SRID, EPSG, ESRI, IGNF, SRORG}
+    public enum Registry {
+        SRID, EPSG, ESRI, IGNF, SRORG
+    }
 
-    private String source;            // The source of SRS information (ex. 
prj file path)
-    private Registry registry = EPSG; // The registry in which this SRS is 
referenced
-    private String code = UNDEFINED;  // The code of the SRS
-    private String description = "";  // The name or description of the SRS
+    private String source = ""; // The source of SRS information (ex. prj file
+                                // path)
+    private Registry registry = EPSG; // The registry in which this SRS is
+                                      // referenced
+    private String code = UNDEFINED; // The code of the SRS
+    private String description = ""; // The name or description of the SRS
     private Unit unit = Unit.UNKNOWN; // The unit used by this SRS
 
-    public SRSInfo() {}
+    public SRSInfo() {
+    }
 
     public String getSource() {
         return source;
@@ -39,9 +44,12 @@
 
     public Registry getRegistry() {
         if (code == null && description == null)
-            throw new IllegalStateException("SRSInfo must have a code or a 
description");
-        if (registry != null) return registry;
-        else return guessRegistry(getCode());
+            throw new IllegalStateException(
+                    "SRSInfo must have a code or a description");
+        if (registry != null)
+            return registry;
+        else
+            return guessRegistry(getCode());
     }
 
     public SRSInfo setRegistry(Registry registry) {
@@ -56,7 +64,8 @@
 
     public String getCode() {
         if (code == null && description == null)
-            throw new IllegalStateException("SRSInfo must have a code or a 
description");
+            throw new IllegalStateException(
+                    "SRSInfo must have a code or a description");
         return code;
     }
 
@@ -67,7 +76,8 @@
 
     public String getDescription() {
         if (code == null && description == null)
-            throw new IllegalStateException("SRSInfo must have a code or a 
description");
+            throw new IllegalStateException(
+                    "SRSInfo must have a code or a description");
         return description;
     }
 
@@ -78,7 +88,8 @@
 
     public Unit getUnit() {
         if (code == null && description == null)
-            throw new IllegalStateException("SRSInfo must have a code or a 
description");
+            throw new IllegalStateException(
+                    "SRSInfo must have a code or a description");
         return unit;
     }
 
@@ -107,19 +118,27 @@
 
     @Override
     public String toString() {
-        return getRegistry().toString() + ':' + getCode() + ' ' + 
getDescription() + " [" + getUnit() + ']';
+        return getRegistry().toString() + ':' + getCode() + ' '
+                + getDescription() + " [" + getUnit() + ']';
     }
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+        if (this == o)
+            return true;
+        if (o == null || getClass() != o.getClass())
+            return false;
 
         SRSInfo srsInfo = (SRSInfo) o;
 
-        if (registry != null ? !registry.equals(srsInfo.registry) : 
srsInfo.registry != null) return false;
-        if (code != null ? !code.equals(srsInfo.code) : srsInfo.code != null) 
return false;
-        if (description != null ? !description.equals(srsInfo.description) : 
srsInfo.description != null) return false;
+        if (registry != null ? !registry.equals(srsInfo.registry)
+                : srsInfo.registry != null)
+            return false;
+        if (code != null ? !code.equals(srsInfo.code) : srsInfo.code != null)
+            return false;
+        if (description != null ? !description.equals(srsInfo.description)
+                : srsInfo.description != null)
+            return false;
         return unit != null ? unit.equals(srsInfo.unit) : srsInfo.unit == null;
 
     }
@@ -128,7 +147,8 @@
     public int hashCode() {
         int result = registry != null ? registry.hashCode() : 0;
         result = 31 * result + (code != null ? code.hashCode() : 0);
-        result = 31 * result + (description != null ? description.hashCode() : 
0);
+        result = 31 * result
+                + (description != null ? description.hashCode() : 0);
         result = 31 * result + (unit != null ? unit.hashCode() : 0);
         return result;
     }

Modified: 
core/trunk/src/org/openjump/core/rasterimage/AddRasterImageLayerWizard.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/AddRasterImageLayerWizard.java 
2017-11-13 21:48:13 UTC (rev 5564)
+++ core/trunk/src/org/openjump/core/rasterimage/AddRasterImageLayerWizard.java 
2017-11-14 10:47:59 UTC (rev 5565)
@@ -208,12 +208,7 @@
         // reused
         // by the plugins
         mih.addMetaInformation("srid", rLayer.getSRSInfo().getCode());
-        if (rLayer.getSRSInfo().getCode().equals("0")) {
-            mih.addMetaInformation("srid-location", "");
-        } else {
-            mih.addMetaInformation("srid-location", rLayer.getSRSInfo()
-                    .getSource());
-        }
+        mih.addMetaInformation("srid-location", 
rLayer.getSRSInfo().getSource());
 
         // ###################################
         context.getLayerManager().addLayerable(catName, rLayer);

Modified: 
core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java
===================================================================
--- 
core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java
     2017-11-13 21:48:13 UTC (rev 5564)
+++ 
core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java
     2017-11-14 10:47:59 UTC (rev 5565)
@@ -30,6 +30,7 @@
 import javax.swing.event.ChangeListener;
 
 import org.openjump.core.apitools.LayerTools;
+import org.openjump.core.ccordsys.utils.ProjUtils;
 import org.openjump.core.ccordsys.utils.SRSInfo;
 import org.openjump.core.ccordsys.utils.SridLookupTable;
 import org.openjump.core.rasterimage.RasterImageLayer;
@@ -494,20 +495,16 @@
         try {
             String srsCode = (String) layer.getMetaInformation().getMetaData()
                     .get("srid");
-
+            String srsLocation = (String) layer.getMetaInformation()
+                    .getMetaData().get("srid-location");
             srsInfo = SridLookupTable.getSrsAndUnitFromCode(srsCode);
             proj_coordinate = srsInfo.toString();
-            String srsLocation = (String) layer.getMetaInformation()
-                    .getMetaData().get("srid-location");
-            if (srsLocation.equals(layer.getImageFileName())) {
-                proj_file_path = GEO_METADATA;
-            } else {
-                proj_file_path = srsLocation;
-            }
+            proj_file_path = srsLocation;
+
         } catch (Exception e) {
-            srsInfo = SridLookupTable.getSrsAndUnitFromCode("0");
+            srsInfo = ProjUtils.getSRSInfoFromLayerSource(layer);
             proj_coordinate = srsInfo.toString();
-            proj_file_path = "";
+            proj_file_path = srsInfo.getSource();
         }
     }
 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to