Package com.yahoo.geo

Class DegreesParser


  • public class DegreesParser
    extends java.lang.Object
    utility for parsing geographical coordinates
    Author:
    arnej27959
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double latitude
      the parsed latitude (degrees north if positive)
      double longitude
      the parsed longitude (degrees east if positive)
    • Constructor Summary

      Constructors 
      Constructor Description
      DegreesParser​(java.lang.String latandlong)
      Parse the given string.
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • latitude

        public double latitude
        the parsed latitude (degrees north if positive)
      • longitude

        public double longitude
        the parsed longitude (degrees east if positive)
    • Constructor Detail

      • DegreesParser

        public DegreesParser​(java.lang.String latandlong)
                      throws java.lang.IllegalArgumentException
        Parse the given string. The string must contain both a latitude and a longitude, separated by a semicolon, in any order. A latitude must contain "N" or "S" and a number signifying degrees north or south. A longitude must contain "E" or "W" and a number signifying degrees east or west. No signs or spaces are allowed.
        Fractional degrees are recommended as the main input format, but degrees plus fractional minutes may be used for testing. You can use the degree sign (U+00B0 as seen in unicode at http://www.unicode.org/charts/PDF/U0080.pdf) to separate degrees from minutes, put the direction (NSEW) between as a separator, or use a small letter 'o' as a replacement for the degrees sign.
        Some valid input formats:
        "N37.416383;W122.024683" → Sunnyvale
        "37N24.983;122W01.481" → same
        "N37°24.983;W122°01.481" → same
        "N63.418417;E10.433033" → Trondheim
        "N63o25.105;E10o25.982" → same
        "E10o25.982;N63o25.105" → same
        "N63.418417;E10.433033" → same
        "63N25.105;10E25.982" → same
        Parameters:
        latandlong - Latitude and longitude separated by semicolon.
        Throws:
        java.lang.IllegalArgumentException