Exemplo n.º 1
0
 private boolean areCoordinatesValid(
     double minlat, double minlon, double maxlat, double maxlon) {
   return LatLon.isValidLat(minlat)
       && LatLon.isValidLat(maxlat)
       && LatLon.isValidLon(minlon)
       && LatLon.isValidLon(maxlon);
 }
Exemplo n.º 2
0
 /**
  * Replies the download area.
  *
  * @return The download area
  */
 public Bounds getDownloadArea() {
   double[] values = new double[4];
   for (int i = 0; i < 4; i++) {
     try {
       values[i] = Double.parseDouble(latlon[i].getText());
     } catch (NumberFormatException x) {
       return null;
     }
   }
   if (!LatLon.isValidLat(values[0]) || !LatLon.isValidLon(values[1])) return null;
   if (!LatLon.isValidLat(values[2]) || !LatLon.isValidLon(values[3])) return null;
   return new Bounds(values);
 }
Exemplo n.º 3
0
 protected Bounds build() {
   double minlon, minlat, maxlon, maxlat;
   try {
     minlat = Double.parseDouble(latlon[0].getText().trim());
     minlon = Double.parseDouble(latlon[1].getText().trim());
     maxlat = Double.parseDouble(latlon[2].getText().trim());
     maxlon = Double.parseDouble(latlon[3].getText().trim());
   } catch (NumberFormatException e) {
     return null;
   }
   if (!LatLon.isValidLon(minlon)
       || !LatLon.isValidLon(maxlon)
       || !LatLon.isValidLat(minlat)
       || !LatLon.isValidLat(maxlat)) return null;
   if (minlon > maxlon) return null;
   if (minlat > maxlat) return null;
   return new Bounds(minlat, minlon, maxlat, maxlon);
 }
Exemplo n.º 4
0
 protected void check() {
   double value = 0;
   try {
     value = Double.parseDouble(tfLonValue.getText());
   } catch (NumberFormatException ex) {
     setErrorMessage(
         tfLonValue,
         tr("The string ''{0}'' is not a valid double value.", tfLonValue.getText()));
     return;
   }
   if (!LatLon.isValidLon(value)) {
     setErrorMessage(
         tfLonValue,
         tr("Value for longitude in range [-180,180] required.", tfLonValue.getText()));
     return;
   }
   resetErrorMessage(tfLonValue);
 }
Exemplo n.º 5
0
 protected static double initLon(double value, boolean roundToOsmPrecision) {
   if (!LatLon.isValidLon(value))
     throw new IllegalArgumentException(tr("Illegal longitude value ''{0}''", value));
   return roundToOsmPrecision ? LatLon.roundToOsmPrecision(value) : value;
 }