Changeset 31746 in osm for applications/editors


Ignore:
Timestamp:
2015-11-15T15:20:17+01:00 (9 years ago)
Author:
donvip
Message:

[josm_importimageplugin] add a unit test for geotiff reading

Location:
applications/editors/josm/plugins/ImportImagePlugin
Files:
50 added
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/ImportImagePlugin/.classpath

    r30416 r31746  
    22<classpath>
    33        <classpathentry kind="src" path="src"/>
     4        <classpathentry kind="src" path="test/unit"/>
    45        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
    56        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
     
    78        <classpathentry combineaccessrules="false" kind="src" path="/JOSM-jts"/>
    89        <classpathentry combineaccessrules="false" kind="src" path="/JOSM-log4j"/>
     10        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    911        <classpathentry kind="output" path="bin"/>
    1012</classpath>
  • applications/editors/josm/plugins/ImportImagePlugin/build.xml

    r31114 r31746  
    1717    <import file="../build-common.xml"/>
    1818
    19         <!--
    20     **********************************************************
    21     ** compile - complies the source tree
    22     **********************************************************
    23     -->
    24         <target name="compile" depends="init">
    25                 <echo message="compiling sources for  ${plugin.jar} ... "/>
    26                 <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}" includeantruntime="false">
    27             <classpath>
    28                 <pathelement location="${josm}"/>
    29                 <fileset dir="../log4j/lib">
    30                     <include name="**/*.jar"/>
    31                 </fileset>
    32                 <fileset dir="../jts/lib">
    33                     <include name="**/*.jar"/>
    34                 </fileset>
    35                 <fileset dir="../geotools/lib">
    36                     <include name="**/*.jar"/>
    37                 </fileset>
    38             </classpath>
    39                         <compilerarg value="-Xlint:deprecation"/>
    40                         <compilerarg value="-Xlint:unchecked"/>
    41                 </javac>
    42         </target>
    43        
     19        <fileset id="plugin.requires.jars" dir="${plugin.dist.dir}">
     20        <include name="log4j.jar"/>
     21        <include name="jts.jar"/>
     22        <include name="geotools.jar"/>
     23    </fileset>
     24
    4425</project>
  • applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java

    r31114 r31746  
    111111                if (val == 3) {
    112112                    logger.debug("No projection and user declined un-projected use");
    113                     throw new LayerCreationCancledException();
     113                    throw new LayerCreationCanceledException();
    114114                }
    115115                CoordinateReferenceSystem src = null;
     
    327327            layerProps.setVisible(true);
    328328        }
    329 
    330     }
    331 
    332     /**
    333      * Exception which represents that the layer creation has been cancled by the
    334      * user.
    335      *
    336      */
    337     class LayerCreationCancledException extends IOException{
     329    }
     330
     331    /**
     332     * Exception which represents that the layer creation has been canceled by the user.
     333     */
     334    class LayerCreationCanceledException extends IOException{
    338335    }
    339336
  • applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImportImageFileImporter.java

    r31114 r31746  
    1414import org.openstreetmap.josm.io.IllegalDataException;
    1515import org.openstreetmap.josm.io.FileImporter;
    16 import org.openstreetmap.josm.plugins.ImportImagePlugin.ImageLayer.LayerCreationCancledException;
     16import org.openstreetmap.josm.plugins.ImportImagePlugin.ImageLayer.LayerCreationCanceledException;
    1717
    1818/**
     
    4747            try {
    4848                layer = new ImageLayer(file);
    49             } catch (LayerCreationCancledException e) {
     49            } catch (LayerCreationCanceledException e) {
    5050            // if user decides that layer should not be created just return.
    5151                continue;
  • applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImportImagePlugin.java

    r30738 r31746  
    9191            loadFileAction = new LoadImageAction();
    9292            loadFileAction.setEnabled(true);
    93             MainMenu.add(Main.main.menu.imagerySubMenu, loadFileAction);
    94 
    95             // add menu entries
    96             //Main.main.menu.fileMenu.insert(loadFileAction, 8);
    97 
    98             //Main.main.menu.fileMenu.insertSeparator(9);
     93            if (Main.main != null) {
     94                MainMenu.add(Main.main.menu.imagerySubMenu, loadFileAction);
     95   
     96                // add menu entries
     97                //Main.main.menu.fileMenu.insert(loadFileAction, 8);
     98                //Main.main.menu.fileMenu.insertSeparator(9);
     99            }
    99100
    100101            ExtensionFileFilter.importers.add(new ImportImageFileImporter());
  • applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/LoadImageAction.java

    r31114 r31746  
    1212import org.openstreetmap.josm.actions.JosmAction;
    1313import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    14 import org.openstreetmap.josm.plugins.ImportImagePlugin.ImageLayer.LayerCreationCancledException;
     14import org.openstreetmap.josm.plugins.ImportImagePlugin.ImageLayer.LayerCreationCanceledException;
    1515
    1616
     
    4646            try {
    4747                layer = new ImageLayer(fc.getSelectedFile());
    48             } catch (LayerCreationCancledException e) {
     48            } catch (LayerCreationCanceledException e) {
    4949                // if user decides that layer should not be created just return.
    5050                return;
  • applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java

    r30738 r31746  
    154154
    155155            BufferedImage img = ImageIO.read(file);
     156            if (img == null) {
     157                throw new IOException("Cannot read image file " + file.getAbsolutePath());
     158            }
    156159
    157160            // create Envelope
     
    336339    {
    337340        GridCoverage2D coverage = null;
    338         Hints hints = new Hints();
     341        Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, true);
    339342        if(refSys != null)
    340343        {
    341344            hints.put(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM, refSys);
    342 
    343         }
    344         // dont't use the EPSG-Factory because of wrong behaviour
    345         hints.put(Hints.CRS_AUTHORITY_FACTORY, CRS.getAuthorityFactory(true));
     345        }
     346        // don't use the EPSG-Factory because of wrong behaviour
     347        //hints.put(Hints.CRS_AUTHORITY_FACTORY, CRS.getAuthorityFactory(true));
    346348
    347349        GeoTiffReader reader = new GeoTiffReader(file, hints);
     
    352354    }
    353355
    354 
    355     /**
    356      * Loads CRS data from an EPSG database and creates descrptions for each one.
     356    /**
     357     * Loads CRS data from an EPSG database and creates descriptions for each one.
    357358     *
    358359     * @param pluginProps
Note: See TracChangeset for help on using the changeset viewer.