Ignore:
Timestamp:
2016-06-01T00:55:28+02:00 (8 years ago)
Author:
donvip
Message:

sonar - fix many issues

File:
1 edited

Legend:

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

    r32060 r32211  
    1414import java.net.MalformedURLException;
    1515import java.net.URL;
     16import java.nio.charset.StandardCharsets;
    1617import java.util.ArrayList;
    1718import java.util.Collection;
     
    3839    private WMSLayer wmsLayer;
    3940    private CadastreInterface wmsInterface;
    40     private String svg = null;
    41     private static EastNorthBound currentView = null;
    42     private EastNorthBound viewBox = null;
     41    private String svg;
     42    private static EastNorthBound currentView;
     43    private EastNorthBound viewBox;
    4344    private static String errorMessage;
    4445
     
    8283    @Override
    8384    protected void finish() {
     85        // Do nothing
    8486    }
    8587
     
    119121                // check if new node is not already created by another new path
    120122                Node nearestNewNode = checkNearestNode(nodeToAdd, svgDataSet.getNodes());
    121                 if (nearestNewNode == nodeToAdd)
     123                if (nodeToAdd.equals(nearestNewNode))
    122124                    svgDataSet.addPrimitive(nearestNewNode);
    123125                wayToAdd.addNode(nearestNewNode); // either a new node or an existing one
     
    175177        double dy = Double.parseDouble(coor[2]);
    176178        for (int i=3; i<coor.length; i+=2){
    177             if (coor[i].equals("")) {
     179            if (coor[i].isEmpty()) {
    178180                eastNorth.clear(); // some paths are just artifacts
    179181                return;
     
    197199     * @return the already existing node (if any), otherwise the new node candidate.
    198200     */
    199     private Node checkNearestNode(Node nodeToAdd, Collection<Node> nodes) {
     201    private static Node checkNearestNode(Node nodeToAdd, Collection<Node> nodes) {
    200202        double epsilon = 0.05; // smallest distance considering duplicate node
    201203        for (Node n : nodes) {
     
    220222    }
    221223
    222     private URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
    223         String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
     224    private static URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
     225        String str = CadastreInterface.BASE_URL+"/scpc/wms?version=1.1&request=GetMap";
    224226        str += "&layers=";
    225227        str += "CDIF:LS2";
     
    243245        wmsInterface.setCookie();
    244246        File file = new File(CadastrePlugin.cacheDir + "building.svg");
    245         String svg = new String();
     247        String svg = "";
    246248        try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {
    247249            if (file.exists())
    248250                file.delete();
    249251            try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true));
    250                  InputStreamReader isr = new InputStreamReader(is);
     252                 InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
    251253                 BufferedReader br = new BufferedReader(isr)) {
    252                 String line="";
     254                String line;
    253255                while ( null!=(line=br.readLine())){
    254256                    line += "\n";
    255                     bos.write(line.getBytes());
     257                    bos.write(line.getBytes(StandardCharsets.UTF_8));
    256258                    svg += line;
    257259                }
Note: See TracChangeset for help on using the changeset viewer.