Changeset 31391 in osm for applications/editors/josm


Ignore:
Timestamp:
2015-07-16T13:56:29+02:00 (9 years ago)
Author:
nokutu
Message:

Rebased master

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

Legend:

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

    r31387 r31391  
    3333   *
    3434   * @param ex {@link ExecutorService} object that is executing this thread.
    35    * @param url
     35   * @param queryString
     36   * @param layer
    3637   */
    3738  public MapillaryImageInfoDownloaderThread(ExecutorService ex, String queryString, MapillaryLayer layer) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java

    r31381 r31391  
    3838  private final MapillarySquareDownloadManagerThread manager;
    3939
    40   public MapillarySequenceDownloadThread(ExecutorService ex, String queryString,
    41       MapillaryLayer layer, MapillarySquareDownloadManagerThread manager) {
     40  /**
     41   * Main constructor.
     42   *
     43   * @param ex
     44   * @param queryString
     45   * @param layer
     46   * @param manager
     47   */
     48  public MapillarySequenceDownloadThread(ExecutorService ex,
     49      String queryString, MapillaryLayer layer,
     50      MapillarySquareDownloadManagerThread manager) {
    4251    this.queryString = queryString;
    4352    this.ex = ex;
     
    5160    try {
    5261      BufferedReader br;
    53       br = new BufferedReader(new InputStreamReader(new URL(URL + queryString).openStream(), "UTF-8"));
     62      br = new BufferedReader(new InputStreamReader(
     63          new URL(URL + queryString).openStream(), "UTF-8"));
    5464      JsonObject jsonall = Json.createReader(br).readObject();
    5565
     
    94104          if (layer.getMapillaryData().getImages().contains(img)) {
    95105            sequence.add(img);
    96             ((MapillaryImage) layer.getMapillaryData().getImages().get(
    97                 layer.getMapillaryData().getImages().indexOf(img))).setSequence(sequence);
     106            ((MapillaryImage) layer.getMapillaryData().getImages()
     107                .get(layer.getMapillaryData().getImages().indexOf(img)))
     108                .setSequence(sequence);
    98109            finalImages.set(
    99110                finalImages.indexOf(img),
    100                 (MapillaryImage) layer.getMapillaryData().getImages().get(
    101                     layer.getMapillaryData().getImages().indexOf(img)));
     111                (MapillaryImage) layer.getMapillaryData().getImages()
     112                    .get(layer.getMapillaryData().getImages().indexOf(img)));
    102113          } else {
    103114            img.setSequence(sequence);
     
    110121          manager.imagesAdded = imagesAdded;
    111122        }
    112         layer.getMapillaryData().addWithoutUpdate(new ArrayList<MapillaryAbstractImage>(
    113             finalImages));
     123        layer.getMapillaryData().addWithoutUpdate(
     124            new ArrayList<MapillaryAbstractImage>(finalImages));
    114125      }
    115126    } catch (IOException e) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySignDownloaderThread.java

    r31387 r31391  
    1717import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    1818
     19/**
     20 * Downloads the signs information in a given area.
     21 *
     22 * @author nokutu
     23 *
     24 */
    1925public class MapillarySignDownloaderThread extends Thread {
    20   private static final String URL = MapillaryDownloader.BASE_URL + "search/im/or/";
     26  private static final String URL = MapillaryDownloader.BASE_URL
     27      + "search/im/or/";
    2128  private final String queryString;
    2229  private final ExecutorService ex;
     
    2633   * Main constructor.
    2734   *
    28    * @param ex {@link ExecutorService} object that is executing this thread.
    29    * @param url
     35   * @param ex
     36   *          {@link ExecutorService} object that is executing this thread.
     37   * @param queryString
     38   * @param layer
    3039   */
    31   public MapillarySignDownloaderThread(ExecutorService ex, String queryString, MapillaryLayer layer) {
     40  public MapillarySignDownloaderThread(ExecutorService ex, String queryString,
     41      MapillaryLayer layer) {
    3242    this.ex = ex;
    3343    this.queryString = queryString;
     
    3949    BufferedReader br;
    4050    try {
    41       br = new BufferedReader(new InputStreamReader(new URL(URL + queryString).openStream(), "UTF-8"));
     51      br = new BufferedReader(new InputStreamReader(
     52          new URL(URL + queryString).openStream(), "UTF-8"));
    4253      JsonObject jsonobj = Json.createReader(br).readObject();
    4354      if (!jsonobj.getBoolean("more")) {
     
    5566            for (int k = 0; k < rects.size(); k++) {
    5667              JsonObject data = rects.getJsonObject(k);
    57               for (MapillaryAbstractImage image : layer.getMapillaryData().getImages())
     68              for (MapillaryAbstractImage image : layer.getMapillaryData()
     69                  .getImages())
    5870                if (image instanceof MapillaryImage
    5971                    && ((MapillaryImage) image).getKey().equals(key))
     
    6779          for (int j = 0; j < rects.size(); j++) {
    6880            JsonObject data = rects.getJsonObject(j);
    69             for (MapillaryAbstractImage image : layer.getMapillaryData().getImages())
     81            for (MapillaryAbstractImage image : layer.getMapillaryData()
     82                .getImages())
    7083              if (image instanceof MapillaryImage
    7184                  && ((MapillaryImage) image).getKey().equals(key))
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java

    r31387 r31391  
    3131  private final String signQueryString;
    3232  private final MapillaryLayer layer;
     33  /** Whether if new images have been added in the download or not. */
    3334  public boolean imagesAdded = false;
    3435
     
    3637   * Main constructor.
    3738   *
    38    * @param urlImages URL used to download the images.
    39    * @param urlSequences URL used to download the sequences.
    40    * @param urlSigns URL used to download the signs.
     39   * @param queryStringParts
     40   * @param layer
     41   *
    4142   */
    42   public MapillarySquareDownloadManagerThread(ConcurrentHashMap<String, Double> queryStringParts, MapillaryLayer layer) {
     43  public MapillarySquareDownloadManagerThread(
     44      ConcurrentHashMap<String, Double> queryStringParts, MapillaryLayer layer) {
    4345    this.imageQueryString = buildQueryString(queryStringParts);
    4446    this.sequenceQueryString = buildQueryString(queryStringParts);
    4547    this.signQueryString = buildQueryString(queryStringParts);
    4648
    47     Main.info("GET " + sequenceQueryString + " (Mapillary plugin)"); // TODO: Move this line to the appropriate place, here's no GET-request
     49    // TODO: Move this line to the appropriate place, here's no GET-request
     50    Main.info("GET " + sequenceQueryString + " (Mapillary plugin)");
    4851
    4952    this.layer = layer;
    5053  }
    5154
    52   //TODO: Maybe move into a separate utility class?
     55  // TODO: Maybe move into a separate utility class?
    5356  private String buildQueryString(ConcurrentHashMap<String, Double> hash) {
    54     StringBuilder ret = new StringBuilder("?client_id=" + MapillaryDownloader.CLIENT_ID);
     57    StringBuilder ret = new StringBuilder("?client_id="
     58        + MapillaryDownloader.CLIENT_ID);
    5559    for (String key : hash.keySet())
    5660      if (key != null)
    5761        try {
    58           ret.append("&" + URLEncoder.encode(key, "UTF-8"))
    59              .append("=" + URLEncoder.encode(String.format(Locale.UK, "%f", hash.get(key)), "UTF-8"));
     62          ret.append("&" + URLEncoder.encode(key, "UTF-8")).append(
     63              "="
     64                  + URLEncoder.encode(
     65                      String.format(Locale.UK, "%f", hash.get(key)), "UTF-8"));
    6066        } catch (UnsupportedEncodingException e) {
    6167          // This should not happen, as the encoding is hard-coded
     
    9096    int page = 0;
    9197    while (!ex.isShutdown()) {
    92       ex.execute(
    93         new MapillarySequenceDownloadThread(
    94           ex,
    95           sequenceQueryString + "&page=" + page + "&limit=10",
    96           layer,
    97           this
    98         )
    99       );
     98      ex.execute(new MapillarySequenceDownloadThread(ex, sequenceQueryString
     99          + "&page=" + page + "&limit=10", layer, this));
    100100      while (ex.getQueue().remainingCapacity() == 0)
    101101        Thread.sleep(500);
     
    125125    int page = 0;
    126126    while (!ex.isShutdown()) {
    127       ex.execute(new MapillarySignDownloaderThread(ex, signQueryString + "&page="
    128           + page + "&limit=20", layer));
     127      ex.execute(new MapillarySignDownloaderThread(ex, signQueryString
     128          + "&page=" + page + "&limit=20", layer));
    129129      while (ex.getQueue().remainingCapacity() == 0)
    130130        Thread.sleep(100);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java

    r31389 r31391  
    5151  /**
    5252   * Main constructor.
     53   * @param ok
    5354   */
    5455  public MapillaryExportDialog(JButton ok) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java

    r31390 r31391  
    6464    panel.add(moveTo);
    6565    JButton oauth = new JButton(new OAuthAction());
    66     oauth.setText("Login");
     66    if (Main.pref.get("mapillary.access-token") == null)
     67      oauth.setText("Login");
     68    else
     69       oauth.setText("Already loged in, click to relogin");
    6770    panel.add(oauth);
    6871    gui.getDisplayPreference().addSubTab(this, "Mapillary", panel);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java

    r31389 r31391  
    1313import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1414import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    15 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    1615import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
    17 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
    1816import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    1917import org.openstreetmap.josm.plugins.mapillary.commands.CommandMoveImage;
     
    5149      return;
    5250    MapillaryAbstractImage closest = getClosest(e.getPoint());
    53     if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && closestTemp != null
     51    if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && closest != null
    5452        && Main.map.mapMode == Main.map.mapModeSelect) {
    5553      this.lastClicked = this.closest;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/PortListener.java

    r31390 r31391  
    44import java.io.InputStreamReader;
    55import java.io.PrintWriter;
     6import java.net.BindException;
    67import java.net.ServerSocket;
    78import java.net.Socket;
     
    4748      in.close();
    4849      serverSocket.close();
     50    } catch (BindException e) {
     51      return;
    4952    } catch (IOException e) {
    5053      Main.error(e);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoGlyph.java

    r31383 r31391  
    1111public class TrafficoGlyph {
    1212  private static Map<String, Character> glyphs;
     13
    1314  private static Map<String, Character> readGlyphsFromResources() {
    14     JsonReader reader = Json.createReader(TrafficoSignElement.class.getResourceAsStream("/data/fonts/traffico/glyphs.json"));
     15    JsonReader reader = Json.createReader(TrafficoSignElement.class
     16        .getResourceAsStream("/data/fonts/traffico/glyphs.json"));
    1517    JsonObject glyphObject = reader.readObject().getJsonObject("glyphs");
    1618    Set<String> glyphNames = glyphObject.keySet();
     
    2123    return glyphs;
    2224  }
     25
    2326  public static Character getGlyph(String key) {
    2427    if (glyphs == null) {
     
    2730    return glyphs.get(key);
    2831  }
     32
    2933  public static void main(String[] args) {
    3034    System.out.println(TrafficoGlyph.getGlyph("h"));
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java

    r31383 r31391  
    3030      System.out.println("Read signs for " + country);
    3131      InputStream countryStream = TrafficoSign.class
    32           .getResourceAsStream("/data/fonts/traffico/signs/" + country + ".json");
    33       if (countryStream == null) { return null; }
     32          .getResourceAsStream("/data/fonts/traffico/signs/" + country
     33              + ".json");
     34      if (countryStream == null) {
     35        return null;
     36      }
    3437      JsonObject countrySigns = Json.createReader(countryStream).readObject();
    3538      Set<String> countrySignNames = countrySigns.keySet();
     
    3841      for (String name : countrySignNames) {
    3942        System.out.println(" * sign " + name);
    40         JsonArray elements = countrySigns.getJsonObject(name).getJsonArray("elements");
    41         List<TrafficoSignElement> layers = new ArrayList<>(); // TODO: Replace by an array when all types of sign
    42                                                               // elements (text!) are supported
     43        JsonArray elements = countrySigns.getJsonObject(name).getJsonArray(
     44            "elements");
     45
     46        // TODO: Replace by an array when all types of sign elements (text!) are
     47        // supported
     48        List<TrafficoSignElement> layers = new ArrayList<>();
     49
    4350        for (int i = 0; i < elements.size(); i++) {
    44           System.out.println("   - " + elements.getJsonObject(i).getString("color") + " layer "
     51          System.out.println("   - "
     52              + elements.getJsonObject(i).getString("color") + " layer "
    4553              + elements.getJsonObject(i).getString("type"));
    46           Character glyph = TrafficoGlyph.getGlyph(elements.getJsonObject(i).getString("type"));
     54          Character glyph = TrafficoGlyph.getGlyph(elements.getJsonObject(i)
     55              .getString("type"));
    4756          if (glyph != null) {
    4857            Color c;
     
    7685      signs.put(country, countryMap);
    7786    }
    78     if (signs.get(country).get(signName) != null) { return signs.get(country).get(signName); }
    79     if (isIn.containsKey(country)) { return TrafficoSign.getSign(isIn.get(country), signName); }
     87    if (signs.get(country).get(signName) != null) {
     88      return signs.get(country).get(signName);
     89    }
     90    if (isIn.containsKey(country)) {
     91      return TrafficoSign.getSign(isIn.get(country), signName);
     92    }
    8093    return null;
    8194  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSignElement.java

    r31383 r31391  
    99
    1010  public TrafficoSignElement(char glyph, Color c) {
    11      if (c == null) {
    12        throw new IllegalArgumentException();
    13      }
    14      this.color = c;
    15      this.glyph = glyph;
     11    if (c == null) {
     12      throw new IllegalArgumentException();
     13    }
     14    this.color = c;
     15    this.glyph = glyph;
    1616  }
    1717
Note: See TracChangeset for help on using the changeset viewer.