Changeset 33047 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-10-30T21:24:41+01:00 (8 years ago)
Author:
donvip
Message:

findbugs

Location:
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r32556 r33047  
    199199        super(info);
    200200        Main.info("Pluging cadastre-fr v"+VERSION+" started...");
     201        initCacheDir();
     202
     203        refreshConfiguration();
     204
     205        UploadAction.registerUploadHook(new CheckSourceUploadHook());
     206
     207        registerSessionLayerExporter(WMSLayer.class, CadastreSessionExporter.class);
     208        registerSessionLayerImporter("cadastre-fr", CadastreSessionImporter.class);
     209    }
     210
     211    private static void initCacheDir() {
    201212        if (Main.pref.get("cadastrewms.cacheDir").isEmpty()) {
    202213            cacheDir = new File(Main.pref.getCacheDirectory(), "cadastrewms").getAbsolutePath();
     
    207218            cacheDir += File.separatorChar;
    208219        Main.info("current cache directory: "+cacheDir);
    209 
    210         refreshConfiguration();
    211 
    212         UploadAction.registerUploadHook(new CheckSourceUploadHook());
    213 
    214         registerSessionLayerExporter(WMSLayer.class, CadastreSessionExporter.class);
    215         registerSessionLayerImporter("cadastre-fr", CadastreSessionImporter.class);
    216220    }
    217221
     
    357361            JMenuItem item = cadastreJMenu.getItem(i);
    358362            if (item != null)
    359                 if (item.getText().equals(MenuActionGrabPlanImage.name) /*||
     363                if (item.getText().equals(MenuActionGrabPlanImage.NAME) /*||
    360364                    item.getText().equals(MenuActionGrab.name) ||
    361365                    item.getText().equals(MenuActionBoundaries.name) ||
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java

    r32556 r33047  
    203203                file.delete();
    204204            try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true));
    205                  InputStreamReader isr = new InputStreamReader(is);
     205                 InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
    206206                 BufferedReader br = new BufferedReader(isr)) {
    207207                String line;
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionBoundaries.java

    r32556 r33047  
    1212
    1313public class MenuActionBoundaries extends JosmAction {
    14    
    15     public static String name = "Administrative boundary";
     14
     15    public static final String NAME = "Administrative boundary";
    1616
    1717    private static final long serialVersionUID = 1L;
    1818    private WMSLayer wmsLayer = null;
    19    
     19
     20    /**
     21     * Constructs a new {@code MenuActionBoundaries}.
     22     */
    2023    public MenuActionBoundaries() {
    21         super(tr(name), "cadastre_small", tr("Extract commune boundary"), null, false);
     24        super(tr(NAME), "cadastre_small", tr("Extract commune boundary"), null, false);
    2225    }
    2326
     
    3538        }
    3639    }
    37 
    3840}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionCancelGrab.java

    r32556 r33047  
    1212public class MenuActionCancelGrab extends JosmAction {
    1313
    14     public static String name = marktr("Cancel current grab");
     14    public static final String NAME = marktr("Cancel current grab");
    1515
    1616    private WMSLayer wmsLayer;
    17    
     17
     18    /**
     19     * Constructs a new {@code MenuActionCancelGrab}.
     20     * @param wmsLayer WMS layer
     21     */
    1822    public MenuActionCancelGrab(WMSLayer wmsLayer) {
    19         super(tr(name), null, tr("Cancel current grab (only vector images)"), null, false);
     23        super(tr(NAME), null, tr("Cancel current grab (only vector images)"), null, false);
    2024        this.wmsLayer = wmsLayer;
    2125    }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrab.java

    r32556 r33047  
    1717public class MenuActionGrab extends JosmAction {
    1818
    19     public static String name = marktr("Cadastre grab");
     19    public static final String NAME = marktr("Cadastre grab");
    2020
     21    /**
     22     * Constructs a new {@code MenuActionGrab}.
     23     */
    2124    public MenuActionGrab() {
    22         super(tr(name), "cadastre_small", tr("Download Image from French Cadastre WMS"),
     25        super(tr(NAME), "cadastre_small", tr("Download Image from French Cadastre WMS"),
    2326                Shortcut.registerShortcut("cadastre:grab", tr("Cadastre: {0}", tr("Download Image from French Cadastre WMS")),
    2427                KeyEvent.VK_F10, Shortcut.DIRECT), false, "cadastrefr/grab", true);
     
    3841            new MenuActionNewLocation().actionPerformed(e);
    3942    }
    40 
    4143}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java

    r32556 r33047  
    2020    private static final long serialVersionUID = 1L;
    2121
    22     public static String name = marktr("Georeference an image");
     22    public static final String NAME = marktr("Georeference an image");
    2323
    2424    private DownloadWMSPlanImage downloadWMSPlanImage;
     
    2626    private RasterImageGeoreferencer rasterImageGeoreferencer;
    2727
     28    /**
     29     * Constructs a new {@code MenuActionGrabPlanImage}.
     30     */
    2831    public MenuActionGrabPlanImage() {
    29         super(tr(name), "cadastre_small", tr("Grab non-georeferenced image"), null, false, "cadastrefr/grabplanimage", true);
     32        super(tr(NAME), "cadastre_small", tr("Grab non-georeferenced image"), null, false, "cadastrefr/grabplanimage", true);
    3033        rasterImageGeoreferencer = new RasterImageGeoreferencer();
    3134    }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionOpenPreferences.java

    r32556 r33047  
    1414    private static final long serialVersionUID = 1L;
    1515
    16     public static String name = marktr("Preferences");
     16    public static final String NAME = marktr("Preferences");
    1717
     18    /**
     19     * Constructs a new {@code MenuActionOpenPreferences}.
     20     */
    1821    public MenuActionOpenPreferences() {
    19         super(tr(name), "cadastre_small", tr("Open Cadastre Preferences"), null, false, "cadastrefr/openpreferences", true);
     22        super(tr(NAME), "cadastre_small", tr("Open Cadastre Preferences"), null, false, "cadastrefr/openpreferences", true);
    2023    }
    2124
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionRefineGeoRef.java

    r32556 r33047  
    1212public class MenuActionRefineGeoRef extends JosmAction {
    1313
    14     public static String name = marktr("Refine georeferencing");
     14    public static final String NAME = marktr("Refine georeferencing");
    1515
    1616    private WMSLayer wmsLayer;
    1717    private RasterImageGeoreferencer rasterImageGeoreferencer;
    1818
     19    /**
     20     * Constructs a new {@code MenuActionRefineGeoRef}.
     21     * @param wmsLayer WMS layer
     22     */
    1923    public MenuActionRefineGeoRef(WMSLayer wmsLayer) {
    20         super(tr(name), null, tr("Improve georeferencing (only raster images)"), null, false);
     24        super(tr(NAME), null, tr("Improve georeferencing (only raster images)"), null, false);
    2125        this.wmsLayer = wmsLayer;
    2226        rasterImageGeoreferencer = new RasterImageGeoreferencer();
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionSaveRasterAs.java

    r32556 r33047  
    99import java.io.File;
    1010import java.io.IOException;
     11import java.util.Locale;
    1112
    1213import javax.imageio.ImageIO;
     
    2930public class MenuActionSaveRasterAs extends JosmAction {
    3031
    31     public static String name = marktr("Save image as...");
     32    public static final String NAME = marktr("Save image as...");
    3233
    3334    private static final long serialVersionUID = 1L;
     
    4142                return true;
    4243            }
    43             return file.getName().toLowerCase().endsWith(".png");
     44            return file.getName().toLowerCase(Locale.ENGLISH).endsWith(".png");
    4445        }
    4546
     
    5657                return true;
    5758            }
    58             return file.getName().toLowerCase().endsWith(".tif");
     59            return file.getName().toLowerCase(Locale.ENGLISH).endsWith(".tif");
    5960        }
    6061
     
    6869    FiltrePng filtrePng = new FiltrePng();
    6970
     71    /**
     72     * Constructs a new {@code MenuActionSaveRasterAs}.
     73     * @param wmsLayer WMS layer
     74     */
    7075    public MenuActionSaveRasterAs(WMSLayer wmsLayer) {
    71         super(tr(name), "save", tr("Export image (only raster images)"), null, false);
     76        super(tr(NAME), "save", tr("Export image (only raster images)"), null, false);
    7277        this.wmsLayer = wmsLayer;
    7378    }
     
    126131                    coverage.dispose(true);
    127132                } catch (Exception e) {
    128                     // TODO Auto-generated catch block
    129                     e.printStackTrace();
     133                    Main.error(e);
    130134                }
    131135            }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageGeoreferencer.java

    r32556 r33047  
    168168  * around org1/dst1 anchor
    169169  * @param org1 first point at original coordinate system (the grabbed image)
    170   * @param org2 second point "
     170  * @param org2 second point
    171171  * @param dst1 first point at final destination coordinate system (the real east/north coordinate system)
    172   * @param dst2 second point "
     172  * @param dst2 second point
    173173  */
    174174 private void affineTransform(EastNorth org1, EastNorth org2, EastNorth dst1, EastNorth dst2) {
     
    188188     double dy = dst1.getY() - org1.getY();
    189189     wmsLayer.getImage(0).shear(dx, dy);
    190      org1 = org1.add(dx, dy); // org1=dst1 now
    191      org2 = org2.add(dx, dy);
    192      // rotate : org1(=dst1 now) is anchor for rotation and scale
     190     // rotate : dst1 is anchor for rotation and scale
    193191     wmsLayer.getImage(0).rotate(dst1, angle);
    194      org2 = org2.rotate(dst1, angle);
    195      // scale image from anchor org1(=dst1 now)
     192     // scale image from anchor dst1
    196193     wmsLayer.getImage(0).scale(dst1, proportion);
    197194 }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/SimplifyWay.java

    r32556 r33047  
    77import org.openstreetmap.josm.data.osm.Node;
    88import org.openstreetmap.josm.data.osm.Way;
     9import org.openstreetmap.josm.data.projection.Ellipsoid;
    910
    1011/**
     
    3435    }
    3536
    36     /*
     37    /**
    3738     * Takes an interval [from,to] and adds nodes from (from,to) to ns.
    3839     * (from and to are indices of wnew.nodes.)
     
    4546        for (int i = from + 1; i < to; i++) {
    4647            Node n = wnew.getNode(i);
    47             double xte = Math.abs(EARTH_RAD
     48            double xte = Math.abs(Ellipsoid.WGS84.a
    4849                    * xtd(fromN.getCoor().lat() * Math.PI / 180, fromN.getCoor().lon() * Math.PI / 180, toN.getCoor().lat() * Math.PI
    4950                            / 180, toN.getCoor().lon() * Math.PI / 180, n.getCoor().lat() * Math.PI / 180, n.getCoor().lon() * Math.PI
     
    6162        }
    6263    }
    63 
    64     public static double EARTH_RAD = 6378137.0;
    6564
    6665    /* From Aviaton Formulary v1.3
Note: See TracChangeset for help on using the changeset viewer.