use of com.twitter.hbc.core.endpoint.Location.Coordinate in project textdb by TextDB.
the class TwitterUtils method getPlaceLocation.
/**
* To track tweets inside a geoBox defined by a List</Location>.
* The string defines the coordinates in the order of "latitude_SW, longitude_SW, latitude_NE, longitude_NE".
*
* @param inputLocation
* @return
* @throws TexeraException
*/
public static List<Location> getPlaceLocation(String inputLocation) throws TexeraException {
List<Location> locationList = new ArrayList<>();
if (inputLocation == null || inputLocation.isEmpty()) {
return locationList;
}
List<String> boudingCoordinate = Arrays.asList(inputLocation.trim().split(","));
if (boudingCoordinate.size() != 4 || boudingCoordinate.stream().anyMatch(s -> s.trim().isEmpty())) {
throw new DataflowException("Please provide valid location coordinates");
}
List<Double> boundingBox = new ArrayList<>();
boudingCoordinate.stream().forEach(s -> boundingBox.add(Double.parseDouble(s.trim())));
locationList.add(new Location(new Coordinate(boundingBox.get(1), boundingBox.get(0)), new Coordinate(boundingBox.get(3), boundingBox.get(2))));
return locationList;
}
Aggregations