Example #1
0
  /**
   * Creates new bounds around a coordinate pair <code>center</code>. The new bounds shall have an
   * extension in latitude direction of <code>latExtent</code>, and in longitude direction of <code>
   * lonExtent</code>.
   *
   * @param center the center coordinate pair. Must not be null.
   * @param latExtent the latitude extent. &gt; 0 required.
   * @param lonExtent the longitude extent. &gt; 0 required.
   * @throws IllegalArgumentException if center is null
   * @throws IllegalArgumentException if latExtent &lt;= 0
   * @throws IllegalArgumentException if lonExtent &lt;= 0
   */
  public Bounds(LatLon center, double latExtent, double lonExtent) {
    CheckParameterUtil.ensureParameterNotNull(center, "center");
    if (latExtent <= 0.0)
      throw new IllegalArgumentException(
          MessageFormat.format(
              "Parameter ''{0}'' > 0.0 expected, got {1}", "latExtent", latExtent));
    if (lonExtent <= 0.0)
      throw new IllegalArgumentException(
          MessageFormat.format(
              "Parameter ''{0}'' > 0.0 expected, got {1}", "lonExtent", lonExtent));

    this.minLat = LatLon.roundToOsmPrecision(LatLon.toIntervalLat(center.lat() - latExtent / 2));
    this.minLon = LatLon.roundToOsmPrecision(LatLon.toIntervalLon(center.lon() - lonExtent / 2));
    this.maxLat = LatLon.roundToOsmPrecision(LatLon.toIntervalLat(center.lat() + latExtent / 2));
    this.maxLon = LatLon.roundToOsmPrecision(LatLon.toIntervalLon(center.lon() + lonExtent / 2));
  }
Example #2
0
 public void normalize() {
   minLat = LatLon.toIntervalLat(minLat);
   maxLat = LatLon.toIntervalLat(maxLat);
   minLon = LatLon.toIntervalLon(minLon);
   maxLon = LatLon.toIntervalLon(maxLon);
 }