Changeset 30858 in osm for applications/editors


Ignore:
Timestamp:
2014-12-19T17:01:02+01:00 (10 years ago)
Author:
donvip
Message:

[josm_cadastre-fr] use correct JOSM cache directory + update of javadoc, Eclipse project, version number

Location:
applications/editors/josm/plugins/cadastre-fr
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/META-INF/MANIFEST.MF

    r29816 r30858  
    22Plugin-Class: cadastre_fr.CadastrePlugin
    33Plugin-Description: A special handler for the French land registry WMS server
    4 Plugin-Version: 2.5
     4Plugin-Version: 2.6
    55Plugin-Stage: 60
    66Plugin-Author: Pieren;<pieren3@gmail.com>
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r30737 r30858  
    33
    44import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
     5import static org.openstreetmap.josm.io.session.SessionReader.registerSessionLayerImporter;
     6import static org.openstreetmap.josm.io.session.SessionWriter.registerSessionLayerExporter;
    57import static org.openstreetmap.josm.tools.I18n.marktr;
    68import static org.openstreetmap.josm.tools.I18n.tr;
    7 import static org.openstreetmap.josm.io.session.SessionWriter.registerSessionLayerExporter;
    8 import static org.openstreetmap.josm.io.session.SessionReader.registerSessionLayerImporter;
    99
    1010import java.awt.event.ActionEvent;
     
    2828import org.openstreetmap.josm.data.projection.AbstractProjection;
    2929import org.openstreetmap.josm.data.projection.Projection;
     30import org.openstreetmap.josm.gui.IconToggleButton;
    3031import org.openstreetmap.josm.gui.MainMenu;
    3132import org.openstreetmap.josm.gui.MapFrame;
    32 import org.openstreetmap.josm.gui.IconToggleButton;
    3333import org.openstreetmap.josm.gui.layer.Layer;
    3434import org.openstreetmap.josm.gui.preferences.PreferenceDialog;
     
    4040
    4141/**
    42  *
    43  * Plugin to access the French Cadastre WMS server at www.cadastre.gouv.fr This
    44  * WMS server requires some specific handling like retrieving a cookie for a
     42 * Plugin to access the French Cadastre WMS server at <a href="http://www.cadastre.gouv.fr">
     43 * www.cadastre.gouv.fr</a>.<br>
     44 * This WMS server requires some specific handling like retrieving a cookie for a
    4545 * limitation in case of no activity, or the request to the server shall provide
    4646 * a city/town/village code.
    4747 *
    4848 * @author Pieren <pieren3@gmail.com>,
    49  * @author <matthieu.lochegnies@gmail.com> for the extension to codeCommune
    50  * @version 0.8
    51  * History:
    52  * 0.1 17-Jun-2008 first prototype using a first Lambert projection impl. in core
    53  * 0.2 22-Jun-2008 first stable version
    54  * 0.3 24-Jun-2008 add code departement
    55  * 0.4 06-Jul-2008 - add images scales, icons, menu items disabling
    56  *                 - remove dependencies of wmsplugin
    57  *                 - add option to force a Lambert zone (for median locations)
    58  *                 - add auto-sourcing
    59  * 0.5 16-Aug-2008 - add transparency in layer (allowing multiple wms layers displayed together)
    60  *                 - no overlapping of grabbed images if transparency is enabled
    61  *                 - set one layer per location
    62  *                 - use utf-8 charset in POST request to server
    63  *                 - improve the preferences setting dialog
    64  *                 - cancel the current download is now possible
    65  *                 - add automatic images caching and load on request (+ manage cache directory size)
    66  *                 - enable auto-sourcing only if a WMS layer is used
    67  * 0.6 18-Aug-2008 - suppress the null-exception message after the dialog 'open a layer first'
    68  *                 - process the overlapping images when cache is loaded from disk
    69  *                 - save the last 'new location request' text again in preferences
    70  *                 - avoid duplicate layers with same name
    71  *                 - set text input for new locations in upper case
    72  *                 - the cache directory is configurable in "cadastrewms.cacheDir"
    73  *                 - improve configuration change updates
    74  * 0.7 24-Aug-2008 - mask images only if transparency enabled
    75  *                 - validate projection name by Lambert.toString() method
    76  * 0.8 25-Jan-2009 - display returned list of communes if direct name is not recognized by server
    77  *                 - new possible grab factor of 100 square meters fixed size
    78  *                 - minor fixes due to changes in JOSM core classes
    79  *                 - first draft of raster image support
    80  * 0.9 05-Feb-2009 - grab vectorized full commune bbox, save in file, convert to OSM way
    81  *                   and simplify
    82  * 1.0 18-Feb-2009 - fix various bugs in color management and preference dialog
    83  *                 - increase PNG picture size requested to WMS (800x1000)
    84  *                 - set 4th grab scale fixed size configurable (from 25 to 1000 meters)
    85  * 1.1 11-Jun-2009 - fixed a null exception error when trying to displace a vectorized layer
    86  *                 - propose to use shortcut F11 for grabbing
    87  * 1.2 16-Aug-2009 - implementation of raster image grabbing, cropping and georeferencing (not the
    88  *                   overview rasters (Tableau d'assemblage) but directly small units (Feuille)
    89  * 1.3 23-Aug-2009 - improve georeferencing action cancellation
    90  *                 - fixed bug of raster image loaded from cache not working on Java1.6
    91  *                 - improve mouse click bounce detection during georeferencing process
    92  * 1.4 25-Oct-2009 - add support for new Lambert CC 9 Zones projection
    93  *                 - add optional crosspieces display on raster image layers
    94  *                 - add automatic raster images georeferencing when WMS provides data
    95  *                 - re-implement manual adjustment mode in raster image layer
    96  * 1.5 21-Nov-2009 - major changes in projection in core : no magical zone prediction anymore for
    97  *                   Lambert 4 and 9 zones; grid translation implemented for Lambert 4 zones;
    98  *                   support of subprojections in preferences for zones setting and UTM20N
    99  *                 - removed autosourcing of empty new nodes
    100  * 1.6 28-Nov-2009 - Fix minor issues if Grab is called without layer (possible since projection rework)
    101  * 1.7 12-Dec-2009 - Change URL's changes for cookie and downgrade imgs resolution due to WMS changes
    102  * 1.8 11-Mar-2010 - filter the mouse button 1 during georeferencing
    103  *                 - retry if getting a new cookie failed (10 times during 30 seconds)
    104  *                 - cookie expiration automatically detected and renewed (after 30 minutes)
    105  *                 - proper WMS layer cleanup at destruction (workaround for memory leak)
    106  *                 - new cache format (v3) storing original image and cropped image bbox + angle
    107  *                 - new cache format (v4) storing original image size for later rotation
    108  *                 - cache files read compatible with previous formats
    109  *                 - raster image rotation issues fixed, now using shift+ctrl key instead of ctrl
    110  *                 - raster image adjustment using default system menu modifier (ctrl for windows) for Mac support
    111  *                 - image resolution configurable (high, medium, low) like the online interface
    112  *                 - layer selection configurable for vectorized images
    113  *                 - improved download cancellation
    114  *                 - from Erik Amzallag:
    115  *                 -     possibility to modify the auto-sourcing text just before upload
    116  *                 - from Clément Ménier:
    117  *                 -     new option allowing an auto-selection of the first cadastre layer for grab
    118  *                 -     non-modal JDialog in MenuActionGrabPlanImage
    119  *                 -     new options in the image filter (bilinear, bicubic)
    120  * 1.9 05-Apr-2010 - added a scroll bar in preferences
    121  *                 - download cancellation improved
    122  *                 - last deployment for Java1.5 compatibility
    123  * 2.0 07-Jul-2010 - update projection for "La Reunion" departement to RGR92, UTM40S.
    124  *                 - add 'departement' as option in the municipality selection
    125  *                 - fixed bug in cache directory size control (and disabled by default)
    126  *                 - add map mode for addressing
    127  *                 - from Nicolas Dumoulin:
    128  *                 -     add "tableau d'assemblage" in raster images for georeferencing (as option)
    129  * 2.1 14-Jan-2011 - add GrabThread moving the grab to a separate thread
    130  *                 - the divided BBox mode starts from the central square and loads the next in a spiral
    131  *                 - move the grabber from CadastrPlugin singleton to each wmsLayer instance to allow grabbing
    132  *                   of multiple municipalities in parallel.
    133  * 2.2 01-Jul-2011 - replace deprecated Main.proj by newest Main.getProjection()
    134  *                 - fix list of raster images (Feuilles) parsing failing after a Cadastre server change/maintenance
    135  * 2.3 11-Jan-2013 - add various improvements from Don-Vip (Vincent Privat) trac #8175, #8229 and #5626.
    136  * 2.4 27-Jun-2013 - fix raster image georeferencing issues. Add new MenuActionRefineGeoRef for a new georeferencing
    137  *                   of already referenced plan image.
    138  * 2.5 06-Aug-2013 - fix transparency issue on new raster images. Temporary disable georeferences parsing not
    139  *                   working on new cadastre WMS.
    140  *                 - workaround on address help tool when switching to full screen
    141  *                 - improvement when clicking on existing node address street in mode relation
    142  *                 - option to simplify raster images in 2 bits colors (like images served in the past).
    143  * 2.6 10-Sep-2013 - add JOSM "sessions" feature support (list of layers stored in a file)                   
     49 *         <matthieu.lochegnies@gmail.com> for the extension to codeCommune
     50 *
     51 * @version 2.6
     52 * <br>History:
     53 * <br>0.1 17-Jun-2008 first prototype using a first Lambert projection impl. in core
     54 * <br>0.2 22-Jun-2008 first stable version
     55 * <br>0.3 24-Jun-2008 add code departement
     56 * <br>0.4 06-Jul-2008 - add images scales, icons, menu items disabling
     57 * <br>                - remove dependencies of wmsplugin
     58 * <br>                - add option to force a Lambert zone (for median locations)
     59 * <br>                - add auto-sourcing
     60 * <br>0.5 16-Aug-2008 - add transparency in layer (allowing multiple wms layers displayed together)
     61 * <br>                - no overlapping of grabbed images if transparency is enabled
     62 * <br>                - set one layer per location
     63 * <br>                - use utf-8 charset in POST request to server
     64 * <br>                - improve the preferences setting dialog
     65 * <br>                - cancel the current download is now possible
     66 * <br>                - add automatic images caching and load on request (+ manage cache directory size)
     67 * <br>                - enable auto-sourcing only if a WMS layer is used
     68 * <br>0.6 18-Aug-2008 - suppress the null-exception message after the dialog 'open a layer first'
     69 * <br>                - process the overlapping images when cache is loaded from disk
     70 * <br>                - save the last 'new location request' text again in preferences
     71 * <br>                - avoid duplicate layers with same name
     72 * <br>                - set text input for new locations in upper case
     73 * <br>                - the cache directory is configurable in "cadastrewms.cacheDir"
     74 * <br>                - improve configuration change updates
     75 * <br>0.7 24-Aug-2008 - mask images only if transparency enabled
     76 * <br>                - validate projection name by Lambert.toString() method
     77 * <br>0.8 25-Jan-2009 - display returned list of communes if direct name is not recognized by server
     78 * <br>                - new possible grab factor of 100 square meters fixed size
     79 * <br>                - minor fixes due to changes in JOSM core classes
     80 * <br>                - first draft of raster image support
     81 * <br>0.9 05-Feb-2009 - grab vectorized full commune bbox, save in file, convert to OSM way
     82 *                       and simplify
     83 * <br>1.0 18-Feb-2009 - fix various bugs in color management and preference dialog
     84 * <br>                - increase PNG picture size requested to WMS (800x1000)
     85 * <br>                - set 4th grab scale fixed size configurable (from 25 to 1000 meters)
     86 * <br>1.1 11-Jun-2009 - fixed a null exception error when trying to displace a vectorized layer
     87 * <br>                - propose to use shortcut F11 for grabbing
     88 * <br>1.2 16-Aug-2009 - implementation of raster image grabbing, cropping and georeferencing (not the
     89 * <br>                  overview rasters (Tableau d'assemblage) but directly small units (Feuille)
     90 * <br>1.3 23-Aug-2009 - improve georeferencing action cancellation
     91 * <br>                - fixed bug of raster image loaded from cache not working on Java1.6
     92 * <br>                - improve mouse click bounce detection during georeferencing process
     93 * <br>1.4 25-Oct-2009 - add support for new Lambert CC 9 Zones projection
     94 * <br>                - add optional crosspieces display on raster image layers
     95 * <br>                - add automatic raster images georeferencing when WMS provides data
     96 * <br>                - re-implement manual adjustment mode in raster image layer
     97 * <br>1.5 21-Nov-2009 - major changes in projection in core : no magical zone prediction anymore for
     98 *                       Lambert 4 and 9 zones; grid translation implemented for Lambert 4 zones;
     99 *                       support of subprojections in preferences for zones setting and UTM20N
     100 * <br>                - removed autosourcing of empty new nodes
     101 * <br>1.6 28-Nov-2009 - Fix minor issues if Grab is called without layer (possible since projection rework)
     102 * <br>1.7 12-Dec-2009 - Change URL's changes for cookie and downgrade imgs resolution due to WMS changes
     103 * <br>1.8 11-Mar-2010 - filter the mouse button 1 during georeferencing
     104 * <br>                - retry if getting a new cookie failed (10 times during 30 seconds)
     105 * <br>                - cookie expiration automatically detected and renewed (after 30 minutes)
     106 * <br>                - proper WMS layer cleanup at destruction (workaround for memory leak)
     107 * <br>                - new cache format (v3) storing original image and cropped image bbox + angle
     108 * <br>                - new cache format (v4) storing original image size for later rotation
     109 * <br>                - cache files read compatible with previous formats
     110 * <br>                - raster image rotation issues fixed, now using shift+ctrl key instead of ctrl
     111 * <br>                - raster image adjustment using default system menu modifier (ctrl for windows) for Mac support
     112 * <br>                - image resolution configurable (high, medium, low) like the online interface
     113 * <br>                - layer selection configurable for vectorized images
     114 * <br>                - improved download cancellation
     115 * <br>                - from Erik Amzallag:
     116 * <br>                -     possibility to modify the auto-sourcing text just before upload
     117 * <br>                - from Clément Ménier:
     118 * <br>                -     new option allowing an auto-selection of the first cadastre layer for grab
     119 * <br>                -     non-modal JDialog in MenuActionGrabPlanImage
     120 * <br>                -     new options in the image filter (bilinear, bicubic)
     121 * <br>1.9 05-Apr-2010 - added a scroll bar in preferences
     122 * <br>                - download cancellation improved
     123 * <br>                - last deployment for Java1.5 compatibility
     124 * <br>2.0 07-Jul-2010 - update projection for "La Reunion" departement to RGR92, UTM40S.
     125 * <br>                - add 'departement' as option in the municipality selection
     126 * <br>                - fixed bug in cache directory size control (and disabled by default)
     127 * <br>                - add map mode for addressing
     128 * <br>                - from Nicolas Dumoulin:
     129 * <br>                -     add "tableau d'assemblage" in raster images for georeferencing (as option)
     130 * <br>2.1 14-Jan-2011 - add GrabThread moving the grab to a separate thread
     131 * <br>                - the divided BBox mode starts from the central square and loads the next in a spiral
     132 * <br>                - move the grabber from CadastrPlugin singleton to each wmsLayer instance to allow grabbing
     133 *                       of multiple municipalities in parallel.
     134 * <br>2.2 01-Jul-2011 - replace deprecated Main.proj by newest Main.getProjection()
     135 * <br>                - fix list of raster images (Feuilles) parsing failing after a Cadastre server change/maintenance
     136 * <br>2.3 11-Jan-2013 - add various improvements from Don-Vip (Vincent Privat) trac #8175, #8229 and #5626.
     137 * <br>2.4 27-Jun-2013 - fix raster image georeferencing issues. Add new MenuActionRefineGeoRef for a new georeferencing
     138 *                       of already referenced plan image.
     139 * <br>2.5 06-Aug-2013 - fix transparency issue on new raster images. Temporary disable georeferences parsing not
     140 *                       working on new cadastre WMS.
     141 * <br>                - workaround on address help tool when switching to full screen
     142 * <br>                - improvement when clicking on existing node address street in mode relation
     143 * <br>                - option to simplify raster images in 2 bits colors (like images served in the past).
     144 * <br>2.6 10-Sep-2013 - add JOSM "sessions" feature support (list of layers stored in a file)
    144145 */
    145146public class CadastrePlugin extends Plugin {
    146     static String VERSION = "2.5";
     147    static String VERSION = "2.6";
    147148
    148149    static JMenu cadastreJMenu;
     
    190191    private static String LAYER_COMMUNE = "CDIF:COMMUNE";
    191192    private static String STYLE_COMMUNE = "COMMUNE_90";
    192    
     193
    193194    /**
    194      * Creates the plugin and setup the default settings if necessary
    195      *
    196      * @throws Exception
     195     * Creates the plugin and setup the default settings if necessary.
     196     * @param info plugin information
    197197     */
    198     public CadastrePlugin(PluginInformation info) throws Exception {
     198    public CadastrePlugin(PluginInformation info) {
    199199        super(info);
    200         System.out.println("Pluging cadastre-fr v"+VERSION+" started...");
    201         if (Main.pref.get("cadastrewms.cacheDir").equals(""))
    202             cacheDir = Main.pref.getPreferencesDir()+"plugins"+File.separatorChar+"cadastrewms"+File.separatorChar;
    203         else {
     200        Main.info("Pluging cadastre-fr v"+VERSION+" started...");
     201        if (Main.pref.get("cadastrewms.cacheDir").isEmpty()) {
     202            cacheDir = new File(Main.pref.getCacheDirectory(), "cadastrewms").getAbsolutePath();
     203        } else {
    204204            cacheDir = Main.pref.get("cadastrewms.cacheDir");
    205             if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar )
    206                 cacheDir += File.separatorChar;
    207         }
    208         System.out.println("current cache directory: "+cacheDir);
     205        }
     206        if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar )
     207            cacheDir += File.separatorChar;
     208        Main.info("current cache directory: "+cacheDir);
    209209
    210210        refreshConfiguration();
    211211
    212212        UploadAction.registerUploadHook(new CheckSourceUploadHook());
    213        
     213
    214214        registerSessionLayerExporter(WMSLayer.class , CadastreSessionExporter.class);
    215215        registerSessionLayerImporter("cadastre-fr", CadastreSessionImporter.class);
    216 
    217216    }
    218217
     
    233232            menuSource.setSelected(autoSourcing);
    234233            menuSource.addActionListener(new ActionListener() {
    235                 public void actionPerformed(ActionEvent ev) {
     234                @Override
     235                                public void actionPerformed(ActionEvent ev) {
    236236                    Main.pref.put("cadastrewms.autosourcing", menuSource.isSelected());
    237237                    autoSourcing = menuSource.isSelected();
     
    350350            grabStyles = grabStyles.substring(0, grabStyles.length()-1);
    351351        } else {
    352             JOptionPane.showMessageDialog(Main.parent,tr("Please enable at least two WMS layers in the cadastre-fr " 
     352            JOptionPane.showMessageDialog(Main.parent,tr("Please enable at least two WMS layers in the cadastre-fr "
    353353                    + "plugin configuration.\nLayers ''Building'' and ''Parcel'' added by default."));
    354354            Main.pref.put("cadastrewms.layerBuilding", true);
     
    378378    }
    379379
    380     public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
     380    @Override
     381        public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    381382        if (cadastreJMenu != null) {
    382383            if (oldFrame == null && newFrame != null) {
     
    496497    }
    497498
    498     public static void askToChangeProjection() { 
    499         if (JOptionPane.showConfirmDialog(Main.parent, 
    500                 tr("To enable the cadastre WMS plugin, change\n" 
    501                         + "the current projection to one of the cadastre\n" 
    502                         + "projections and retry"), 
    503                         tr("Change the current projection"), JOptionPane.OK_CANCEL_OPTION) 
    504             == JOptionPane.OK_OPTION) { 
    505             PreferenceDialog p = new PreferenceDialog(Main.parent); 
    506             p.selectPreferencesTabByClass(MapPreference.class); 
    507             p.getTabbedPane().getSetting(ProjectionPreference.class).selectProjection(ProjectionPreference.lambert_cc9); 
    508             p.setVisible(true); 
    509         } 
    510         }
     499    public static void askToChangeProjection() {
     500        if (JOptionPane.showConfirmDialog(Main.parent,
     501                tr("To enable the cadastre WMS plugin, change\n"
     502                        + "the current projection to one of the cadastre\n"
     503                        + "projections and retry"),
     504                        tr("Change the current projection"), JOptionPane.OK_CANCEL_OPTION)
     505            == JOptionPane.OK_OPTION) {
     506            PreferenceDialog p = new PreferenceDialog(Main.parent);
     507            p.selectPreferencesTabByClass(MapPreference.class);
     508            p.getTabbedPane().getSetting(ProjectionPreference.class).selectProjection(ProjectionPreference.lambert_cc9);
     509            p.setVisible(true);
     510        }
     511    }
    511512}
Note: See TracChangeset for help on using the changeset viewer.