Changeset 28954 in osm


Ignore:
Timestamp:
2012-11-18T22:21:44+01:00 (12 years ago)
Author:
donvip
Message:

[josm_importimage] Major refactoring/update of COTS in order to rely on GeoTools plugin

Location:
applications/editors/josm/plugins/ImportImagePlugin
Files:
3 added
24 deleted
8 edited

Legend:

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

    • Property svn:ignore
      •  

        old new  
        11build
         2bin
  • applications/editors/josm/plugins/ImportImagePlugin/.classpath

    r25934 r28954  
    22<classpath>
    33        <classpathentry kind="src" path="src"/>
    4         <classpathentry kind="lib" path="lib/commons-beanutils-1.7.0.jar"/>
    5         <classpathentry kind="lib" path="lib/commons-pool-1.5.3.jar"/>
    6         <classpathentry kind="lib" path="lib/geoapi-2.3-M1.jar"/>
    7         <classpathentry kind="lib" path="lib/geoapi-pending-2.3-M1.jar"/>
    8         <classpathentry kind="lib" path="lib/geoapi.jar"/>
    9         <classpathentry kind="lib" path="lib/gt-api-2.6.0.jar"/>
    10         <classpathentry kind="lib" path="lib/gt-coverage-2.6.0.jar"/>
    11         <classpathentry kind="lib" path="lib/gt-epsg-extension-2.6.0.jar"/>
    12         <classpathentry kind="lib" path="lib/gt-epsg-hsql-2.6.0.jar"/>
    13         <classpathentry kind="lib" path="lib/gt-geotiff-2.6.0.jar"/>
    14         <classpathentry kind="lib" path="lib/gt-main-2.6.0.jar"/>
    15         <classpathentry kind="lib" path="lib/gt-metadata-2.6.0.jar"/>
    16         <classpathentry kind="lib" path="lib/gt-referencing-2.6.0.jar"/>
    17         <classpathentry kind="lib" path="lib/hsqldb-1.8.0.7.jar"/>
    18         <classpathentry kind="lib" path="lib/imageio-ext-tiff-1.0.4.jar"/>
    19         <classpathentry kind="lib" path="lib/imageio-ext-utilities-1.0.4.jar"/>
    20         <classpathentry kind="lib" path="lib/jai_codec-1.1.3.jar"/>
    21         <classpathentry kind="lib" path="lib/jai_core.jar"/>
    22         <classpathentry kind="lib" path="lib/jai_imageio-1.1.jar"/>
    23         <classpathentry kind="lib" path="lib/jdom-1.0.jar"/>
    24         <classpathentry kind="lib" path="lib/jsr-275-1.0-beta-2.jar"/>
    25         <classpathentry kind="lib" path="lib/jts-1.10.jar"/>
    26         <classpathentry kind="lib" path="lib/log4j-1.2.12.jar"/>
    27         <classpathentry kind="lib" path="lib/vecmath-1.3.2.jar"/>
     4        <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
    285        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    296        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
     7        <classpathentry combineaccessrules="false" kind="src" path="/JOSM-GeoTools"/>
     8        <classpathentry combineaccessrules="false" kind="src" path="/JOSM-jts"/>
     9        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/commons-beanutils-1.7.0.jar"/>
     10        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/commons-pool-1.5.4.jar"/>
     11        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/hsqldb-1.8.0.7.jar"/>
     12        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/jai_codec-1.1.3.jar"/>
     13        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/jai_core-1.1.3.jar"/>
     14        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/jai_imageio-1.1.jar"/>
     15        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/jdom-1.0.jar"/>
     16        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/jsr-275-1.0-beta-2.jar"/>
     17        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/vecmath-1.3.2.jar"/>
     18        <classpathentry kind="lib" path="/JOSM-jts/lib/jts-1.12.jar"/>
     19        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-api-8.3.jar"/>
     20        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-coverage-8.3.jar"/>
     21        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-epsg-extension-8.3.jar"/>
     22        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-epsg-hsql-8.3.jar"/>
     23        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-geotiff-8.3.jar"/>
     24        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-main-8.3.jar"/>
     25        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-metadata-8.3.jar"/>
     26        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-referencing-8.3.jar"/>
     27        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/imageio-ext-tiff-1.1.5.jar"/>
     28        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/imageio-ext-utilities-1.1.5.jar"/>
     29        <classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-opengis-8.3.jar"/>
    3030        <classpathentry kind="output" path="bin"/>
    3131</classpath>
  • applications/editors/josm/plugins/ImportImagePlugin/.project

    r25934 r28954  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<projectDescription>
    3         <name>ImportImagePlugin</name>
     3        <name>JOSM-ImportImage</name>
    44        <comment></comment>
    55        <projects>
  • applications/editors/josm/plugins/ImportImagePlugin/build.xml

    r27354 r28954  
    4545        <!-- this is the directory where the plugin jar is copied to -->
    4646        <property name="plugin.dist.dir"        value="../../dist"/>
    47         <property name="ant.build.javac.target" value="1.5"/>
     47        <property name="ant.build.javac.target" value="1.6"/>
    4848        <property name="plugin.dist.dir"        value="../../dist"/>
    4949        <property name="plugin.jar"             value="${plugin.dist.dir}/${ant.project.name}.jar"/>
     
    6565        <target name="compile" depends="init">
    6666                <echo message="compiling sources for  ${plugin.jar} ... "/>
    67                 <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}">
     67                <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}" includeantruntime="false">
    6868            <classpath>
    6969                <pathelement location="${josm}"/>
    7070                <fileset dir="lib">
     71                    <include name="**/*.jar"/>
     72                </fileset>
     73                <fileset dir="../jts/lib">
     74                    <include name="**/*.jar"/>
     75                </fileset>
     76                <fileset dir="../geotools/lib">
    7177                    <include name="**/*.jar"/>
    7278                </fileset>
     
    8591                <echo message="creating ${ant.project.name}.jar ... "/>
    8692               
    87                 <copy todir="${plugin.build.dir}/lib">
    88                         <fileset dir="lib">
    89                                   <not>
    90                                     <filename name="log4j-1.2.12.jar"/>
    91                                   </not>
    92                         </fileset>
    93                 </copy>
    94         <unjar src="lib/log4j-1.2.12.jar" dest="${plugin.build.dir}"/>
     93        <unjar src="lib/log4j-1.2.17.jar" dest="${plugin.build.dir}"/>
    9594                <copy todir="${plugin.build.dir}/images">
    9695                        <fileset dir="images"/>
     
    124123                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/ImportImagePlugin"/>
    125124                <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
     125                <attribute name="Plugin-Requires" value="geotools"/>
    126126                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    127127                        </manifest>
     
    273273        </target>
    274274       
    275         <target name="unjar-test" >
    276         <!--unjar dest="C:/Workspace_2/geotoolstest/lib/unjartest">
    277             <fileset dir="lib"/>
    278         </unjar-->
    279        
    280                         <jar destfile="C:/Workspace_2/geotoolstest/lib/unjartest/${ant.project.name}.jar" basedir="C:/Workspace_2/geotoolstest/lib/unjartest">
    281 
    282                         <manifest>
    283                 <attribute name="Author" value="Christoph Beekmans, Fabian Kowitz, Anna Robaszkiewicz, Oliver Kuhn, Martin Ulitzny"/>
    284                 <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.CoveragePlugin.CoveragePlugin"/>
    285                 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
    286                 <attribute name="Plugin-Description" value="Plugin for importing spatial referenced images"/>
    287                 <attribute name="Plugin-Link" value="..."/>
    288                 <attribute name="Plugin-Mainversion" value=".."/>
    289                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    290                 <attribute name="Class-path" value=" . CoveragePlugin/lib/commons-beanutils-1.7.0.jar CoveragePlugin/lib/commons-pool-1.5.3.jar CoveragePlugin/lib/geoapi-2.3-M1.jar CoveragePlugin/lib/geoapi-pending-2.3-M1.jar CoveragePlugin/lib/geoapi.jar CoveragePlugin/lib/gt-api-2.6.0.jar CoveragePlugin/lib/gt-coverage-2.6.0.jar CoveragePlugin/lib/gt-epsg-extension-2.6.0.jar CoveragePlugin/lib/gt-epsg-hsql-2.6.0.jar CoveragePlugin/lib/gt-geotiff-2.6.0.jar CoveragePlugin/lib/gt-main-2.6.0.jar CoveragePlugin/lib/gt-metadata-2.6.0.jar CoveragePlugin/lib/gt-referencing-2.6.0.jar CoveragePlugin/lib/hsqldb-1.8.0.7.jar CoveragePlugin/lib/imageio-ext-tiff-1.0.4.jar CoveragePlugin/lib/imageio-ext-utilities-1.0.4.jar CoveragePlugin/lib/jai_codec-1.1.3.jar CoveragePlugin/lib/jai_core.jar CoveragePlugin/lib/jai_imageio-1.1.jar CoveragePlugin/lib/jdom-1.0.jar CoveragePlugin/lib/jsr-275-1.0-beta-2.jar CoveragePlugin/lib/jts-1.10.jar CoveragePlugin/lib/log4j-1.2.12.jar CoveragePlugin/lib/vecmath-1.3.2.jar" />
    291                         </manifest>
    292                 </jar>
    293         </target>
    294        
    295275</project>
  • applications/editors/josm/plugins/ImportImagePlugin/resources/pluginProperties.properties

    r23145 r28954  
    11default_crs_srid=EPSG\:31467
    22default_crs_eastingfirst=true
    3 libraries=commons-beanutils-1.7.0.jar,commons-pool-1.5.3.jar,geoapi-2.3-M1.jar,geoapi-pending-2.3-M1.jar,gt-api-2.6.0.jar,gt-coverage-2.6.0.jar,gt-epsg-hsql-2.6.0.jar,gt-geotiff-2.6.0.jar,gt-main-2.6.0.jar,gt-metadata-2.6.0.jar,gt-referencing-2.6.0.jar,hsqldb-1.8.0.7.jar,imageio-ext-tiff-1.0.4.jar,imageio-ext-utilities-1.0.4.jar,jai_codec-1.1.3.jar,jai_core.jar,jai_imageio-1.1.jar,jdom-1.0.jar,jsr-275-1.0-beta-2.jar,jts-1.10.jar,vecmath-1.3.2.jar
  • applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java

    r26517 r28954  
    1111
    1212import javax.media.jai.PlanarImage;
     13import javax.swing.AbstractAction;
    1314import javax.swing.Action;
    14 import javax.swing.AbstractAction;
    1515import javax.swing.Icon;
    1616import javax.swing.ImageIcon;
     
    2929import org.openstreetmap.josm.data.ProjectionBounds;
    3030import org.openstreetmap.josm.data.coor.EastNorth;
    31 import org.openstreetmap.josm.data.coor.LatLon;
    3231import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    3332import org.openstreetmap.josm.gui.ExtendedDialog;
     
    208207
    209208            // Draw picture
    210             g.drawImage(image, 0, 0, null);
     209            try {
     210                g.drawImage(image, 0, 0, null);
     211            } catch (ArrayIndexOutOfBoundsException e) {
     212                // TODO: prevents this to happen when displaying GeoTIFF images (see #7902)
     213                e.printStackTrace();
     214            }
    211215
    212216        } else {
  • applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImportImagePlugin.java

    r26452 r28954  
    8787            }
    8888
    89             /* Change class path:
    90              * Use java reflection methods to add URLs to the class-path.
    91              * Changes take effect when calling methods of other plugin classes
    92              * (new threads)
    93              * */
    94             URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
    95             String[] libraryNames = pluginProps.getProperty("libraries").split(",");
    96             Class<URLClassLoader> sysclass = URLClassLoader.class;
    97             Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class});
    98             method.setAccessible(true);
    99             for (int i = 0; i < libraryNames.length; i++) {
    100                 File library = new File(PLUGINLIBRARIES_DIR + "/" + libraryNames[i]);
    101                 method.invoke(sysLoader, new Object[]{library.toURI().toURL()});
    102             }
    103 
    104 
    10589            // load information about supported reference systems
    10690            PluginOperations.loadCRSData(pluginProps);
     
    11397            Main.main.menu.fileMenu.insert(loadFileAction, 8);
    11498            Main.main.menu.fileMenu.insertSeparator(9);
    115 
    11699
    117100        } catch (Exception e) {
     
    125108
    126109        logger.info("Plugin successfully loaded.");
    127 
    128110    }
    129111
     
    136118    private void checkInstallation() throws IOException
    137119    {
    138 
    139120        // check plugin resource state
    140121        boolean isInstalled = true;
     
    186167            }
    187168
    188 
    189             // Copy all needed JAR files to $PLUGIN_DIR$/lib/
    190             String[] libStrings = pluginProps.getProperty("libraries").split(",");
    191 
    192             for (int i = 0; i < libStrings.length; i++) {
    193 
    194                 URL url = pluginClassLoader.getResource("lib/" + libStrings[i]);
    195 
    196                 FileOutputStream out = null;
    197 
    198                 try{
    199                     out = new FileOutputStream(new File(libDir, libStrings[i]));
    200                 } catch (FileNotFoundException e) {
    201                     break;
    202                 }
    203 
    204                 BufferedInputStream in = null;
    205                 try
    206                 {
    207                     in = new BufferedInputStream(url.openStream());
    208 
    209                     byte[] buffer = new byte[1024];
    210                     while (true)
    211                     {
    212                         int count = in.read(buffer);
    213                         if (count == -1)
    214                             break;
    215                         out.write(buffer, 0, count);
    216                     }
    217                 }
    218                 finally
    219                 {
    220                     if (in != null)
    221                         in.close();
    222                 }
    223             }
    224169            logger.debug("Plugin successfully installed");
    225170        }
  • applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java

    r26452 r28954  
    1919import org.geotools.coverage.grid.GridCoverage2D;
    2020import org.geotools.coverage.grid.GridCoverageFactory;
    21 import org.geotools.coverage.processing.DefaultProcessor;
     21import org.geotools.coverage.processing.CoverageProcessor;
    2222import org.geotools.data.DataSourceException;
    2323import org.geotools.data.WorldFileReader;
     
    2525import org.geotools.gce.geotiff.GeoTiffReader;
    2626import org.geotools.geometry.Envelope2D;
    27 import org.geotools.image.jai.Registry;
    2827import org.geotools.referencing.CRS;
    29 import org.geotools.referencing.crs.DefaultGeographicCRS;
    30 import org.opengis.metadata.content.ImageDescription;
    3128import org.opengis.parameter.ParameterValueGroup;
    3229import org.opengis.referencing.FactoryException;
     
    3431import org.opengis.referencing.crs.CRSAuthorityFactory;
    3532import org.opengis.referencing.crs.CoordinateReferenceSystem;
    36 import org.opengis.referencing.cs.CoordinateSystemAxis;
    3733import org.opengis.util.InternationalString;
    38 
    39 
    4034
    4135/**
     
    8478        GridCoverage2D destination = null;
    8579
    86         DefaultProcessor processor = new DefaultProcessor(null);
    87         ParameterValueGroup resampleParams = processor.getOperation("Resample")
    88                 .getParameters();
     80        CoverageProcessor processor = new CoverageProcessor();
     81        ParameterValueGroup resampleParams = processor.getOperation("Resample").getParameters();
    8982
    9083        // set parameters
    9184        resampleParams.parameter("Source").setValue(coverage);
    92         resampleParams.parameter("CoordinateReferenceSystem").setValue(
    93                 targetCrs);
     85        resampleParams.parameter("CoordinateReferenceSystem").setValue(targetCrs);
    9486
    9587        // resample coverage with given parameters
     
    380372        CRSAuthorityFactory fac = CRS.getAuthorityFactory(false);
    381373
    382         for (Iterator iterator = supportedCodes.iterator(); iterator.hasNext();) {
     374        for (Iterator<String> iterator = supportedCodes.iterator(); iterator.hasNext();) {
    383375            String string = (String) iterator.next();
    384376            try {
     
    387379                }
    388380                InternationalString desc = fac.getDescriptionText("EPSG:" + string);
    389 
    390381                String description = desc.toString() + " [-EPSG:" + string + "-]";
    391 
    392382                crsDescriptions.add(description);
    393 
    394383                if(defaultcrsString != null && defaultcrsString.equalsIgnoreCase("EPSG:" + string)){
    395384                    boolean isEastingFirst = Boolean.valueOf(pluginProps.getProperty("default_crs_eastingfirst"));
     
    397386                    defaultSourceCRSDescription = description;
    398387                }
    399             } catch (NoSuchAuthorityCodeException e) {
    400                 logger.error("Error while loading EPSG data: " + e.getMessage());
     388
    401389            } catch (FactoryException e) {
    402390                logger.error("Error while loading EPSG data: " + e.getMessage());
     
    404392        }
    405393    }
    406 
    407394}
Note: See TracChangeset for help on using the changeset viewer.