Codota Logo
DegreesParser.<init>
Code IndexAdd Codota to your IDE (free)

How to use
com.yahoo.geo.DegreesParser
constructor

Best Java code snippets using com.yahoo.geo.DegreesParser.<init> (Showing top 2 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: com.yahoo.vespa/document

public static Struct fromString(String str) {
  try {
    DegreesParser d = new DegreesParser(str);
    return valueOf((int)(d.longitude * 1000000), (int)(d.latitude * 1000000));
  } catch (IllegalArgumentException e) {
    try {
      String[] arr = str.split(";");
      if (arr.length == 2) {
        int x = Integer.parseInt(arr[0]);
        int y = Integer.parseInt(arr[1]);
        return valueOf(x, y);
      }
    } catch (NumberFormatException nfe) {
      // empty
    }
    throw new IllegalArgumentException("Could not parse '"+str+"' as geo coordinates: "+e.getMessage());
  }
}
origin: com.yahoo.vespa/container-search

private void handleGeoCircle(Query query, String ll, Location target) {
  double ewCoord;
  double nsCoord;
  try {
    DegreesParser parsed = new DegreesParser(ll);
    ewCoord = parsed.longitude;
    nsCoord = parsed.latitude;
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Unable to parse lat/long string '" +ll + "'", e);
  }
  String radius = query.properties().getString(posRadius);
  double radiusdegrees;
  if (radius == null) {
    radiusdegrees = 50.0 * km2deg;
  } else if (radius.endsWith("km")) {
    double radiuskm = Double.valueOf(radius.substring(0, radius.length()-2));
    radiusdegrees = radiuskm * km2deg;
  } else if (radius.endsWith("m")) {
    double radiusm = Double.valueOf(radius.substring(0, radius.length()-1));
    radiusdegrees = radiusm * km2deg / 1000.0;
  } else if (radius.endsWith("mi")) {
    double radiusmiles = Double.valueOf(radius.substring(0, radius.length()-2));
    radiusdegrees = radiusmiles * mi2deg;
  } else {
    radiusdegrees = Integer.parseInt(radius) * 0.000001;
  }
  target.setGeoCircle(nsCoord, ewCoord, radiusdegrees);
}
com.yahoo.geoDegreesParser<init>

Javadoc

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\u00B024.983;W122\u00B001.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

Popular methods of DegreesParser

  • getNextChar
  • isCompassDirection
  • isDigit

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • getSharedPreferences (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • LinkedHashMap (java.util)
    Hash table and linked list implementation of the Map interface, with predictable iteration order. Th
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now