Class CountryBoundaries


  • public class CountryBoundaries
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.util.Set<java.lang.String> getContainingIds​(double minLongitude, double minLatitude, double maxLongitude, double maxLatitude)
      Identify which countries are guaranteed to contain the given bounding box fully.
      java.util.List<java.lang.String> getIds​(double longitude, double latitude)  
      java.util.Set<java.lang.String> getIntersectingIds​(double minLongitude, double minLatitude, double maxLongitude, double maxLatitude)
      Identify which countries intersect with the given bounding box.
      int hashCode()  
      boolean isIn​(double longitude, double latitude, java.lang.String id)  
      boolean isInAny​(double longitude, double latitude, java.util.Collection<java.lang.String> ids)  
      static CountryBoundaries load​(java.io.InputStream is)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • load

        public static CountryBoundaries load​(java.io.InputStream is)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • isInAny

        public boolean isInAny​(double longitude,
                               double latitude,
                               java.util.Collection<java.lang.String> ids)
        Parameters:
        longitude - longitude of geo position (-180...180)
        latitude - latitude of geo position (-90...90)
        ids - ids of the countries to look for. Note that if you have many ids, you should use a Set to increase performance
        Returns:
        whether the given position is in any of the countries with the given ids
        Throws:
        java.lang.IllegalArgumentException - if any parameter is not finite (NaN or Infinite) or latitude is not between -90.0 and +90.0
      • isIn

        public boolean isIn​(double longitude,
                            double latitude,
                            java.lang.String id)
        Parameters:
        longitude - longitude of geo position (-180...180)
        latitude - latitude of geo position (-90...90)
        id - id of the country to look for
        Returns:
        whether the given position is in the country with the given id
        Throws:
        java.lang.IllegalArgumentException - if any parameter is not finite (NaN or Infinite) or latitude is not between -90.0 and +90.0
      • getIds

        public java.util.List<java.lang.String> getIds​(double longitude,
                                                       double latitude)
        Parameters:
        longitude - longitude of geo position (-180...180)
        latitude - latitude of geo position (-90...90)
        Returns:
        the ids of the countries the given position is contained in, ordered by size ascending
      • getContainingIds

        public java.util.Set<java.lang.String> getContainingIds​(double minLongitude,
                                                                double minLatitude,
                                                                double maxLongitude,
                                                                double maxLatitude)
        Identify which countries are guaranteed to contain the given bounding box fully. The given bounding box may wrap around the 180th longitude, i.e minLongitude = 170 and maxLongitude = -170.
        Parameters:
        minLongitude - minimum longitude of geo position (-180...180)
        minLatitude - minimum latitude of geo position (-90...90)
        maxLongitude - maximum longitude of geo position (-180...180)
        maxLatitude - maximum latitude of geo position (-90...90)
        Returns:
        the ids of the countries the given bounding box is guaranteed to be contained in, not in any particular order
        Throws:
        java.lang.IllegalArgumentException - if any parameter is not finite (NaN or Infinite), minLatitude is greater than maxLatitude or any latitude is not between -90.0 and +90.0
      • getIntersectingIds

        public java.util.Set<java.lang.String> getIntersectingIds​(double minLongitude,
                                                                  double minLatitude,
                                                                  double maxLongitude,
                                                                  double maxLatitude)
        Identify which countries intersect with the given bounding box. The given bounding box may wrap around the 180th longitude, i.e minLongitude = 170 and maxLongitude = -170.
        Parameters:
        minLongitude - minimum longitude of geo position (-180...180)
        minLatitude - minimum latitude of geo position (-90...90)
        maxLongitude - maximum longitude of geo position (-180...180)
        maxLatitude - maximum latitude of geo position (-90...90)
        Returns:
        the ids of the countries the given bounding box intersects with, not in any particular order
        Throws:
        java.lang.IllegalArgumentException - if any parameter is not finite (NaN or Infinite), minLatitude is greater than maxLatitude or any latitude is not between -90.0 and +90.0
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object