private boolean areCoordinatesValid( double minlat, double minlon, double maxlat, double maxlon) { return LatLon.isValidLat(minlat) && LatLon.isValidLat(maxlat) && LatLon.isValidLon(minlon) && LatLon.isValidLon(maxlon); }
/** * 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); }
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); }
protected void check() { double value = 0; try { value = Double.parseDouble(tfLatValue.getText()); } catch (NumberFormatException ex) { setErrorMessage( tfLatValue, tr("The string ''{0}'' is not a valid double value.", tfLatValue.getText())); return; } if (!LatLon.isValidLat(value)) { setErrorMessage( tfLatValue, tr("Value for latitude in range [-90,90] required.", tfLatValue.getText())); return; } resetErrorMessage(tfLatValue); }
protected static double initLat(double value, boolean roundToOsmPrecision) { if (!LatLon.isValidLat(value)) throw new IllegalArgumentException(tr("Illegal latitude value ''{0}''", value)); return roundToOsmPrecision ? LatLon.roundToOsmPrecision(value) : value; }