diff options
Diffstat (limited to 'main/src/cgeo/geocaching/geopoint/Geopoint.java')
| -rw-r--r-- | main/src/cgeo/geocaching/geopoint/Geopoint.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java index c718a5f..1655343 100644 --- a/main/src/cgeo/geocaching/geopoint/Geopoint.java +++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java @@ -572,4 +572,31 @@ public final class Geopoint implements ICoordinates, Parcelable { return angdeg * DEG_TO_RAD; } + /** + * Check whether a latitude built from user supplied data is valid. We accept both N90/S90. + * + * @return <tt>true</tt> if the latitude looks valid, <tt>false</tt> otherwise + */ + public static boolean isValidLatitude(final double latitude) { + return latitude >= -90 && latitude <= 90; + } + + /** + * Check whether a lo bngitudeuilt from user supplied data is valid. We accept both E180/W180. + * + * @return <tt>true</tt> if the longitude looks valid, <tt>false</tt> otherwise + */ + public static boolean isValidLongitude(final double longitude) { + return longitude >= -180 && longitude <= 180; + } + + /** + * Check whether a geopoint built from user supplied data is valid. We accept both N90/S90 and E180/W180. + * + * @return <tt>true</tt> if the geopoint looks valid, <tt>false</tt> otherwise + */ + public boolean isValid() { + return isValidLatitude(latitude) && isValidLongitude(longitude); + } + } |
