public static Boolean inFence(double latitude, double longitude, String geofences) {
Coordinates location = Coordinates.of(longitude, latitude);
Boolean inzone = false;
FeatureCollection featureCollection;
try {
featureCollection = GSON.fromJson(geofences, FeatureCollection.class);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(String.format("String %s is not a valid geoJson representation of fence",
geofences), e);
} catch (JsonSyntaxException e) {
throw new IllegalArgumentException(String.format("String %s is not a valid Json string", geofences), e);
}
for (Feature feature : featureCollection.features()) {
inzone = inzone || isPointInside(feature, location);
}
return inzone;
}