Пример #1
0
  /**
   * Sets the current bounding box in this bbox chooser without emiting a property change event.
   *
   * @param bbox the bounding box. null to reset the bounding box
   */
  public void setBoundingBox(Bounds bbox) {
    if (bbox == null) {
      this.bbox = null;
      return;
    }
    // test if a bounding box has been set
    if (bbox.getMin().lat() == 0.0
        && bbox.getMin().lon() == 0.0
        && bbox.getMax().lat() == 0.0
        && bbox.getMax().lon() == 0.0) {
      this.bbox = null;
    }

    int y1 = OsmMercator.LatToY(bbox.getMin().lat(), MAX_ZOOM);
    int y2 = OsmMercator.LatToY(bbox.getMax().lat(), MAX_ZOOM);
    int x1 = OsmMercator.LonToX(bbox.getMin().lon(), MAX_ZOOM);
    int x2 = OsmMercator.LonToX(bbox.getMax().lon(), MAX_ZOOM);

    iSelectionRectStart = new Point(Math.min(x1, x2), Math.min(y1, y2));
    iSelectionRectEnd = new Point(Math.max(x1, x2), Math.max(y1, y2));

    // calc the screen coordinates for the new selection rectangle
    MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMin().lat(), bbox.getMin().lon());
    MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMax().lat(), bbox.getMax().lon());

    Vector<MapMarker> marker = new Vector<MapMarker>(2);
    marker.add(xmin_ymin);
    marker.add(xmax_ymax);
    setMapMarkerList(marker);
    setDisplayToFitMapMarkers();
    zoomOut();
    this.bbox = bbox;
  }
Пример #2
0
 /**
  * Inverse of scale2Zoom
  *
  * @param zoom
  * @return
  */
 public double zoom2Scale(int zoom) {
   return Math.max(
       world.east() / OsmMercator.falseEasting(zoom),
       world.north() / OsmMercator.falseNorthing(zoom));
 }