Changeset 32383 in osm


Ignore:
Timestamp:
2016-06-23T17:42:43+02:00 (8 years ago)
Author:
floscher
Message:

[mapillary] Add methods to access both the original and the current ca/latlon of an image

Until now only the current values were publicly available.

This patch has been supplied by peterneubauer<peter@…>.

Location:
applications/editors/josm/plugins/mapillary
Files:
16 edited

Legend:

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

    r32382 r32383  
    6565
    6666  /**
    67    * Returns the direction towards the image has been taken.
     67   * Returns the original direction towards the image has been taken.
    6868   *
    6969   * @return The direction of the image (0 means north and goes clockwise).
    7070   */
    7171  public double getCa() {
    72     return this.movingCa;
     72    return this.ca;
    7373  }
    7474
     
    121121
    122122  /**
     123  * Returns a LatLon object containing the original coordinates of the object.
     124  *
     125  * @return The LatLon object with the position of the object.
     126  */
     127  public LatLon getLatLon() {
     128    return latLon;
     129  }
     130
     131  /**
     132 * Returns the direction towards the image has been taken.
     133 *
     134 * @return The direction of the image (0 means north and goes clockwise).
     135 */
     136public double getMovingCa() {
     137  return this.movingCa;
     138}
     139
     140  /**
    123141   * Returns a LatLon object containing the current coordinates of the object.
    124142   * When you are dragging the image this changes.
     
    126144   * @return The LatLon object with the position of the object.
    127145   */
    128   public LatLon getLatLon() {
    129     return this.movingLatLon;
     146  public LatLon getMovingLatLon() {
     147    return movingLatLon;
    130148  }
    131149
     
    168186   */
    169187  public boolean isModified() {
    170     return !this.getLatLon().equals(this.latLon) || Math.abs(this.getCa() - this.ca) > EPSILON;
     188    return !this.getMovingLatLon().equals(this.latLon) || Math.abs(this.getMovingCa() - this.ca) > EPSILON;
    171189  }
    172190
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java

    r32373 r32383  
    376376    }
    377377    if (zoom && Main.main != null)
    378       Main.map.mapView.zoomTo(getSelectedImage().getLatLon());
     378      Main.map.mapView.zoomTo(getSelectedImage().getMovingLatLon());
    379379    if (Main.main != null)
    380380      Main.map.mapView.repaint();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r32374 r32383  
    299299    if (this.data.getSelectedImage() != null) {
    300300      MapillaryImage[] closestImages = getClosestImagesFromDifferentSequences();
    301       Point selected = mv.getPoint(this.data.getSelectedImage().getLatLon());
     301      Point selected = mv.getPoint(this.data.getSelectedImage().getMovingLatLon());
    302302      if (closestImages[0] != null) {
    303303        blue = closestImages[0];
    304304        g.setColor(Color.BLUE);
    305         final Point p = mv.getPoint(closestImages[0].getLatLon());
     305        final Point p = mv.getPoint(closestImages[0].getMovingLatLon());
    306306        g.draw(new Line2D.Double(p.getX(), p.getY(), selected.getX(), selected.getY()));
    307307        MapillaryMainDialog.getInstance().blueButton.setEnabled(true);
     
    310310        red = closestImages[1];
    311311        g.setColor(Color.RED);
    312         final Point p = mv.getPoint(closestImages[1].getLatLon());
     312        final Point p = mv.getPoint(closestImages[1].getMovingLatLon());
    313313        g.draw(new Line2D.Double(p.getX(), p.getY(), selected.getX(), selected.getY()));
    314314        MapillaryMainDialog.getInstance().redButton.setEnabled(true);
     
    331331    }
    332332    for (MapillaryAbstractImage imageAbs : this.data.getImages()) {
    333       if (imageAbs.isVisible() && Main.map.mapView.contains(Main.map.mapView.getPoint(imageAbs.getLatLon()))) {
    334         final Point p = mv.getPoint(imageAbs.getLatLon());
     333      if (imageAbs.isVisible() && Main.map.mapView.contains(Main.map.mapView.getPoint(imageAbs.getMovingLatLon()))) {
     334        final Point p = mv.getPoint(imageAbs.getMovingLatLon());
    335335        ImageIcon icon = MapillaryPlugin.MAP_ICON;
    336336        if (getData().getMultiSelectedImages().contains(imageAbs)) {
     
    393393
    394394    // Rotate the image
    395     double rotationRequired = Math.toRadians(image.getCa());
     395    double rotationRequired = Math.toRadians(image.getMovingCa());
    396396    double locationX = width / 2d;
    397397    double locationY = height / 2d;
     
    446446        SEQUENCE_MAX_JUMP_DISTANCE
    447447    };
    448     LatLon selectedCoords = this.data.getSelectedImage().getLatLon();
     448    LatLon selectedCoords = this.data.getSelectedImage().getMovingLatLon();
    449449    for (MapillaryAbstractImage imagePrev : this.data.getImages()) {
    450450      if (!(imagePrev instanceof MapillaryImage))
     
    453453        continue;
    454454      MapillaryImage image = (MapillaryImage) imagePrev;
    455       if (image.getLatLon().greatCircleDistance(selectedCoords) < SEQUENCE_MAX_JUMP_DISTANCE
     455      if (image.getMovingLatLon().greatCircleDistance(selectedCoords) < SEQUENCE_MAX_JUMP_DISTANCE
    456456          && selected.getSequence() != image.getSequence()) {
    457457        if (
    458458            ret[0] == null && ret[1] == null
    459             || image.getLatLon().greatCircleDistance(selectedCoords) < distances[0]
     459            || image.getMovingLatLon().greatCircleDistance(selectedCoords) < distances[0]
    460460            && (ret[1] == null || image.getSequence() != ret[1].getSequence())
    461461        ) {
    462462          ret[0] = image;
    463           distances[0] = image.getLatLon().greatCircleDistance(selectedCoords);
    464         } else if ((ret[1] == null || image.getLatLon().greatCircleDistance(
     463          distances[0] = image.getMovingLatLon().greatCircleDistance(selectedCoords);
     464        } else if ((ret[1] == null || image.getMovingLatLon().greatCircleDistance(
    465465            selectedCoords) < distances[1])
    466466            && image.getSequence() != ret[0].getSequence()) {
    467467          ret[1] = image;
    468           distances[1] = image.getLatLon().greatCircleDistance(selectedCoords);
     468          distances[1] = image.getMovingLatLon().greatCircleDistance(selectedCoords);
    469469        }
    470470      }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayer.java

    r32067 r32383  
    9999    for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData().getImages()) {
    100100      if (img instanceof MapillaryImage) {
    101         g.fillOval(mv.getPoint(img.getLatLon()).x - 3, mv.getPoint(img.getLatLon()).y - 3, 6, 6);
     101        g.fillOval(mv.getPoint(img.getMovingLatLon()).x - 3, mv.getPoint(img.getMovingLatLon()).y - 3, 6, 6);
    102102        if (!((MapillaryImage) img).getSigns().isEmpty()) {
    103           Point imgLoc = mv.getPoint(img.getLatLon());
     103          Point imgLoc = mv.getPoint(img.getMovingLatLon());
    104104          // TODO: Paint a sign from the image
    105105        }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java

    r32373 r32383  
    4343      throw new IllegalStateException();
    4444    Main.map.mapView.zoomTo(MapillaryLayer.getInstance().getData()
    45         .getSelectedImage().getLatLon());
     45        .getSelectedImage().getMovingLatLon());
    4646  }
    4747
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThread.java

    r32069 r32383  
    130130  private static boolean isInside(MapillaryAbstractImage image) {
    131131    for (Bounds b : MapillaryLayer.getInstance().getData().getBounds()) {
    132       if (b.contains(image.getLatLon())) {
     132      if (b.contains(image.getMovingLatLon())) {
    133133        return true;
    134134      }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/export/MapillaryExportWriterThread.java

    r32373 r32383  
    124124        gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);
    125125        gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION,
    126             RationalNumber.valueOf(mimg.getCa()));
     126            RationalNumber.valueOf(mimg.getMovingCa()));
    127127
    128128        exifDirectory.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
     
    134134              ((MapillaryImage) mimg).getDate("yyyy/MM/dd HH/mm/ss"));
    135135        }
    136         outputSet.setGPSInDegrees(mimg.getLatLon().lon(), mimg.getLatLon().lat());
     136        outputSet.setGPSInDegrees(mimg.getMovingLatLon().lon(), mimg.getMovingLatLon().lat());
    137137        OutputStream os = new BufferedOutputStream(new FileOutputStream(finalPath + ".jpg"));
    138138        new ExifRewriter().updateExifMetadataLossless(imageBytes, os, outputSet);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java

    r31972 r32383  
    4242    MapillaryAbstractImage closest = null;
    4343    for (MapillaryAbstractImage image : this.data.getImages()) {
    44       Point imagePoint = Main.map.mapView.getPoint(image.getLatLon());
     44      Point imagePoint = Main.map.mapView.getPoint(image.getMovingLatLon());
    4545      imagePoint.setLocation(imagePoint.getX(), imagePoint.getY());
    4646      double dist = clickPoint.distanceSq(imagePoint);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java

    r32329 r32383  
    8282    if (this.lastClick != null) {
    8383      g.setColor(Color.WHITE);
    84       Point p0 = mv.getPoint(this.lastClick.getLatLon());
     84      Point p0 = mv.getPoint(this.lastClick.getMovingLatLon());
    8585      Point p1 = this.lastPos.getPoint();
    8686      g.drawLine(p0.x, p0.y, p1.x, p1.y);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java

    r32373 r32383  
    136136    if (this.data.getSelectedImage() == null)
    137137      return;
    138     if (this.data.getSelectedImage().getTempCa() != this.data.getSelectedImage().getCa()) {
     138    if (this.data.getSelectedImage().getTempCa() != this.data.getSelectedImage().getMovingCa()) {
    139139      double from = this.data.getSelectedImage().getTempCa();
    140       double to = this.data.getSelectedImage().getCa();
     140      double to = this.data.getSelectedImage().getMovingCa();
    141141      this.record.addCommand(new CommandTurn(this.data.getMultiSelectedImages(), to
    142142              - from));
    143143    } else if (this.data.getSelectedImage().getTempLatLon() != this.data
    144             .getSelectedImage().getLatLon()) {
     144            .getSelectedImage().getMovingLatLon()) {
    145145      LatLon from = this.data.getSelectedImage().getTempLatLon();
    146       LatLon to = this.data.getSelectedImage().getLatLon();
     146      LatLon to = this.data.getSelectedImage().getMovingLatLon();
    147147      this.record.addCommand(new CommandMove(this.data.getMultiSelectedImages(), to
    148148              .getX() - from.getX(), to.getY() - from.getY()));
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java

    r31987 r32383  
    178178    gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);
    179179    gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION,
    180             RationalNumber.valueOf(image.getCa()));
     180            RationalNumber.valueOf(image.getMovingCa()));
    181181
    182182    exifDirectory.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
     
    187187    rootDirectory.removeField(TiffTagConstants.TIFF_TAG_IMAGE_DESCRIPTION);
    188188
    189     outputSet.setGPSInDegrees(image.getLatLon().lon(), image.getLatLon().lat());
     189    outputSet.setGPSInDegrees(image.getMovingLatLon().lon(), image.getMovingLatLon().lat());
    190190    File tempFile = File.createTempFile("imagetoupload_" + c, ".tmp");
    191191    c++;
     
    216216  public static void upload(MapillaryImportedImage image, UUID uuid) {
    217217    String key = MapillaryUser.getUsername() + "/" + uuid.toString() + "/"
    218             + image.getLatLon().lat() + "_" + image.getLatLon().lon() + "_"
    219             + image.getCa() + "_" + image.getCapturedAt() + ".jpg";
     218            + image.getMovingLatLon().lat() + "_" + image.getMovingLatLon().lon() + "_"
     219            + image.getMovingCa() + "_" + image.getCapturedAt() + ".jpg";
    220220
    221221    String policy;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapViewGeometryUtil.java

    r31985 r32383  
    5858    for (MapillaryAbstractImage img : seq.getImages()) {
    5959      if (img.isVisible()) {
    60         Point p = mv.getPoint(img.getLatLon());
     60        Point p = mv.getPoint(img.getMovingLatLon());
    6161        if (path.getCurrentPoint() == null) {
    6262          path.moveTo(p.getX(), p.getY());
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java

    r32378 r32383  
    214214        zoomBounds = new Bounds(new LatLon(0, 0));
    215215      } else {
    216         zoomBounds = new Bounds(images.iterator().next().getLatLon());
     216        zoomBounds = new Bounds(images.iterator().next().getMovingLatLon());
    217217        for (MapillaryAbstractImage img : images) {
    218           zoomBounds.extend(img.getLatLon());
     218          zoomBounds.extend(img.getMovingLatLon());
    219219        }
    220220      }
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/ImportTest.java

    r32034 r32383  
    2828    File image = new File("images/icon16.png");
    2929    MapillaryImportedImage img = ImageUtil.readImagesFrom(image, new LatLon(0, 0)).get(0);
    30     assertEquals(0, img.getCa(), 0.01);
    31     assertTrue(new LatLon(0, 0).equalsEpsilon(img.getLatLon()));
     30    assertEquals(0, img.getMovingCa(), 0.01);
     31    assertTrue(new LatLon(0, 0).equalsEpsilon(img.getMovingLatLon()));
    3232  }
    3333
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java

    r32065 r32383  
    120120    this.record.addCommand(cmd1);
    121121
    122     assertEquals(0.1, this.img1.getLatLon().lat(), 0.01);
    123 
    124     this.record.undo();
    125 
    126     assertEquals(0.0, this.img1.getLatLon().lat(), 0.01);
    127 
    128     this.record.redo();
    129 
    130     assertEquals(0.1, this.img1.getLatLon().lat(), 0.01);
    131 
    132     this.record.addCommand(cmd2);
    133     this.record.undo();
    134 
    135     assertEquals(-0.1, this.img1.getLatLon().lat(), 0.01);
    136 
    137     this.record.redo();
    138 
    139     assertEquals(0.1, this.img1.getLatLon().lat(), 0.01);
     122    assertEquals(0.1, this.img1.getMovingLatLon().lat(), 0.01);
     123
     124    this.record.undo();
     125
     126    assertEquals(0.0, this.img1.getMovingLatLon().lat(), 0.01);
     127
     128    this.record.redo();
     129
     130    assertEquals(0.1, this.img1.getMovingLatLon().lat(), 0.01);
     131
     132    this.record.addCommand(cmd2);
     133    this.record.undo();
     134
     135    assertEquals(-0.1, this.img1.getMovingLatLon().lat(), 0.01);
     136
     137    this.record.redo();
     138
     139    assertEquals(0.1, this.img1.getMovingLatLon().lat(), 0.01);
    140140  }
    141141
     
    155155    this.record.undo();
    156156
    157     assertEquals(-0.1, this.img1.getCa(), 0.01);
    158 
    159     this.record.redo();
    160 
    161     assertEquals(0.1, this.img1.getCa(), 0.01);
    162 
    163     this.record.addCommand(cmd2);
    164     this.record.undo();
    165 
    166     assertEquals(-0.2, this.img1.getCa(), 0.01);
    167 
    168     this.record.redo();
    169 
    170     assertEquals(0.1, this.img1.getCa(), 0.01);
     157    assertEquals(-0.1, this.img1.getMovingCa(), 0.01);
     158
     159    this.record.redo();
     160
     161    assertEquals(0.1, this.img1.getMovingCa(), 0.01);
     162
     163    this.record.addCommand(cmd2);
     164    this.record.undo();
     165
     166    assertEquals(-0.2, this.img1.getMovingCa(), 0.01);
     167
     168    this.record.redo();
     169
     170    assertEquals(0.1, this.img1.getMovingCa(), 0.01);
    171171  }
    172172
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/ImageUtilsTest.java

    r32053 r32383  
    2323    List<MapillaryImportedImage> images = ImageUtil.readImagesFrom(untaggedFile, defaultLL);
    2424    assertEquals(1, images.size());
    25     assertEquals(0, images.get(0).getCa(), 1e-9);
    26     assertEquals(defaultLL, images.get(0).getLatLon());
     25    assertEquals(0, images.get(0).getMovingCa(), 1e-9);
     26    assertEquals(defaultLL, images.get(0).getMovingLatLon());
    2727    assertEquals(untaggedFile, images.get(0).getFile());
    2828    long endTime = System.currentTimeMillis() / 1000 * 1000 + 1000; // Rounding to next full second
     
    3737    List<MapillaryImportedImage> images = ImageUtil.readImagesFrom(untaggedFile, defaultLL);
    3838    assertEquals(1, images.size());
    39     assertEquals(0, images.get(0).getCa(), 1e-9);
    40     assertEquals(55.6052777777, images.get(0).getLatLon().lat(), 1e-9);
    41     assertEquals(13.0001388888, images.get(0).getLatLon().lon(), 1e-9);
     39    assertEquals(0, images.get(0).getMovingCa(), 1e-9);
     40    assertEquals(55.6052777777, images.get(0).getMovingLatLon().lat(), 1e-9);
     41    assertEquals(13.0001388888, images.get(0).getMovingLatLon().lon(), 1e-9);
    4242    assertEquals(untaggedFile, images.get(0).getFile());
    4343    long endTime = System.currentTimeMillis() / 1000 * 1000 + 1000; // Rounding to next full second
     
    5252    List<MapillaryImportedImage> images = ImageUtil.readImagesFrom(untaggedFile, defaultLL);
    5353    assertEquals(1, images.size());
    54     assertEquals(42.73, images.get(0).getCa(), 1e-9);
    55     assertEquals(defaultLL, images.get(0).getLatLon());
     54    assertEquals(42.73, images.get(0).getMovingCa(), 1e-9);
     55    assertEquals(defaultLL, images.get(0).getMovingLatLon());
    5656    assertEquals(untaggedFile, images.get(0).getFile());
    5757    long endTime = System.currentTimeMillis() / 1000 * 1000 + 1000; // Rounding to next full second
     
    6666    List<MapillaryImportedImage> images = ImageUtil.readImagesFrom(untaggedFile, defaultLL);
    6767    assertEquals(1, images.size());
    68     assertEquals(0, images.get(0).getCa(), 1e-9);
    69     assertEquals(defaultLL, images.get(0).getLatLon());
     68    assertEquals(0, images.get(0).getMovingCa(), 1e-9);
     69    assertEquals(defaultLL, images.get(0).getMovingLatLon());
    7070    assertEquals(untaggedFile, images.get(0).getFile());
    7171    /* http://www.wolframalpha.com/input/?i=convert+2015-12-24T01%3A02%3A03%2B0000+to+unixtime */
Note: See TracChangeset for help on using the changeset viewer.