Package de.westnordost.countryboundaries
Class CountryBoundaries
- java.lang.Object
-
- de.westnordost.countryboundaries.CountryBoundaries
-
public class CountryBoundaries extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(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.inthashCode()booleanisIn(double longitude, double latitude, java.lang.String id)booleanisInAny(double longitude, double latitude, java.util.Collection<java.lang.String> ids)static CountryBoundariesload(java.io.InputStream is)
-
-
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-