Changeset 32341 in osm


Ignore:
Timestamp:
2016-06-20T17:21:21+02:00 (8 years ago)
Author:
floscher
Message:

Fix some problems detected by code analysis

Missing JavaDoc, public attributes that can be final, unnecessary initialization with null, …

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java

    r32078 r32341  
    3232  protected double ca;
    3333  /** Temporal position of the picture until it is uploaded. */
    34   public LatLon tempLatLon;
     34  private LatLon tempLatLon;
    3535  /**
    3636   * When the object is being dragged in the map, the temporal position is
    3737   * stored here.
    3838   */
    39   public LatLon movingLatLon;
     39  private LatLon movingLatLon;
    4040  /** Temporal direction of the picture until it is uploaded */
    41   public double tempCa;
     41  private double tempCa;
    4242  /**
    4343   * When the object direction is being moved in the map, the temporal direction
     
    132132  /**
    133133   * Returns the sequence which contains this image.
     134   * Never null.
    134135   *
    135136   * @return The MapillarySequence object that contains this MapillaryImage.
    136137   */
    137138  public MapillarySequence getSequence() {
    138     if (this.sequence == null) {
    139       this.sequence = new MapillarySequence();
    140       this.sequence.add(this);
    141     }
    142 
     139    if (sequence == null) {
     140      sequence = new MapillarySequence();
     141      sequence.add(this);
     142    }
    143143    return this.sequence;
    144144  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryImageInfoDownloadThread.java

    r32069 r32341  
    55import java.io.IOException;
    66import java.io.InputStreamReader;
    7 import java.net.MalformedURLException;
    87import java.util.concurrent.ExecutorService;
    98
     
    1110import javax.json.JsonArray;
    1211import javax.json.JsonObject;
     12import javax.json.JsonReader;
    1313
    1414import org.openstreetmap.josm.Main;
     
    5050      ));
    5151    ) {
    52       JsonObject jsonobj = Json.createReader(br).readObject();
    53       if (!jsonobj.getBoolean("more"))
    54         this.ex.shutdown();
    55       JsonArray jsonarr = jsonobj.getJsonArray("ims");
    56       JsonObject data;
    57       for (int i = 0; i < jsonarr.size(); i++) {
    58         data = jsonarr.getJsonObject(i);
    59         String key = data.getString("key");
    60         for (MapillaryAbstractImage image : MapillaryLayer.getInstance().getData().getImages()) {
    61           if (
    62             image instanceof MapillaryImage
    63               && ((MapillaryImage) image).getKey().equals(key)
    64               && ((MapillaryImage) image).getUser() == null
    65           ) {
    66             ((MapillaryImage) image).setUser(data.getString("user"));
    67             ((MapillaryImage) image).setCapturedAt(data.getJsonNumber("captured_at").longValue());
     52      try (JsonReader reader = Json.createReader(br)) {
     53        JsonObject jsonObj = reader.readObject();
     54        if (!jsonObj.getBoolean("more"))
     55          this.ex.shutdown();
     56        JsonArray jsonArr = jsonObj.getJsonArray("ims");
     57        JsonObject data;
     58        for (int i = 0; i < jsonArr.size(); i++) {
     59          data = jsonArr.getJsonObject(i);
     60          String key = data.getString("key");
     61          for (MapillaryAbstractImage image : MapillaryLayer.getInstance().getData().getImages()) {
     62            if (
     63              image instanceof MapillaryImage
     64                && ((MapillaryImage) image).getKey().equals(key)
     65                && ((MapillaryImage) image).getUser() == null
     66            ) {
     67              ((MapillaryImage) image).setUser(data.getString("user"));
     68              ((MapillaryImage) image).setCapturedAt(data.getJsonNumber("captured_at").longValue());
     69            }
    6870          }
    6971        }
    7072      }
    71     } catch (MalformedURLException e) {
    72       Main.error(e);
    7373    } catch (IOException e) {
    7474      Main.error(e);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryURL.java

    r32069 r32341  
    7979   * @param bounds the bounds in which you want to search for images
    8080   * @param page number of the page to retrieve from the API
    81    * @param selector
     81   * @param selector if set, only a specific type of image is returned by the URL
    8282   * @return the API-URL which gives you the images in the given bounds as JSON
    8383   */
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java

    r32034 r32341  
    9090   * @param format The format of the date.
    9191   * @return The date in Epoch format.
    92    * @throws ParseException
     92   * @throws ParseException if the date cannot be parsed with the given format
    9393   */
    9494  public static long getEpoch(String date, String format) throws ParseException {
     
    153153
    154154  /**
    155    * Joins two images into the same sequence.
    156    *
    157    * @param mapillaryAbstractImage
    158    * @param mapillaryAbstractImage2
     155   * Joins two images into the same sequence. One of them must be the last image of a sequence, the other one the beginning of a different one.
     156   *
     157   * @param mapillaryAbstractImage the first image, into whose sequence the images from the sequence of the second image are merged
     158   * @param mapillaryAbstractImage2 the second image, whose sequence is merged into the sequence of the first image
    159159   */
    160160  public static synchronized void join(
     
    210210      });
    211211    } else {
    212       Bounds zoomBounds = null;
     212      Bounds zoomBounds;
    213213      if (images.isEmpty()) {
    214214        zoomBounds = new Bounds(new LatLon(0, 0));
     
    236236
    237237  /**
    238    * Separates two images belonging to the same sequence.
    239    *
    240    * @param mapillaryAbstractImage
    241    * @param mapillaryAbstractImage2
     238   * Separates two images belonging to the same sequence. The two images have to be consecutive in the same sequence.
     239   * Two new sequences are created and all images up to (and including) either {@code imgA} or {@code imgB} (whichever appears first in the sequence) are put into the first of the two sequences.
     240   * All others are put into the second new sequence.
     241   *
     242   * @param mapillaryAbstractImage one of the images marking where to split the sequence
     243   * @param mapillaryAbstractImage2 the other image marking where to split the sequence, needs to be a direct neighbour of {@code mapillaryAbstractImage} in the sequence.
    242244   */
    243245  public static synchronized void unjoin(
Note: See TracChangeset for help on using the changeset viewer.