@Test public void testTest1() throws Exception { String jsonObjectString1 = "{\"contributors\":null,\"truncated\":false,\"text\":\"Looks we are gone miss the show!?\uD83D\uDE01 #dohatraffic stay at home folks \uD83D\uDE02 https: JsonObject object1 = getJsonObject(jsonObjectString1); jsonReader.close(); boolean test = strictLocationFilter.test(object1); assertTrue(test); String jsonObjectString2 = "{\"contributors\": null, \"truncated\": false, \"text\": \"This ugly scene became the daily normal on #Doha express way :(#Qatar #carcrash #highway #accednt @\u2026 http: JsonObject object2 = getJsonObject(jsonObjectString2); jsonReader.close(); boolean failTest = strictLocationFilter.test(object2); assertFalse(failTest); }
@Override public boolean test(JsonObject t) { JsonValue c = t.get("coordinates"); if (c.getValueType() != ValueType.OBJECT) { return false; } JsonObject coordinates = (JsonObject) c; if (!"Point".equals(coordinates.getString("type"))){ return false; } JsonArray a = coordinates.getJsonArray("coordinates"); assert a.size() == 2; double lon = a.getJsonNumber(0).doubleValue(); double lat = a.getJsonNumber(1).doubleValue(); for (BRect r : square) { if (lon < r.minLon || lon > r.maxLon) continue; if (lat >= r.minLat || lat <= r.maxLat) return true; } return false; }
StrictLocationFilter implements Predicate<JsonObject> { @Override public boolean test(JsonObject t) { JsonValue c = t.get("coordinates"); if (c.getValueType() != ValueType.OBJECT) { return false; } JsonObject coordinates = (JsonObject) c; if (!"Point".equals(coordinates.getString("type"))){ return false; } JsonArray a = coordinates.getJsonArray("coordinates"); assert a.size() == 2; double lon = a.getJsonNumber(0).doubleValue(); double lat = a.getJsonNumber(1).doubleValue(); for (BRect r : square) { if (lon < r.minLon || lon > r.maxLon) continue; if (lat >= r.minLat || lat <= r.maxLat) return true; } return false; } }
StrictLocationFilter implements Predicate<JsonObject> { @Override public boolean test(JsonObject t) { JsonValue c = t.get("coordinates"); if (c.getValueType() != ValueType.OBJECT) { return false; } JsonObject coordinates = (JsonObject) c; if (!"Point".equals(coordinates.getString("type"))){ return false; } JsonArray a = coordinates.getJsonArray("coordinates"); assert a.size() == 2; double lon = a.getJsonNumber(0).doubleValue(); double lat = a.getJsonNumber(1).doubleValue(); for (BRect r : square) { if (lon < r.minLon || lon > r.maxLon) continue; if (lat >= r.minLat || lat <= r.maxLat) return true; } return false; } StrictLocationFilter(TwitterCollectionTask task); }
StrictLocationFilter implements Predicate<JsonObject> { @Override public boolean test(JsonObject t) { JsonValue c = t.get("coordinates"); if (c.getValueType() != ValueType.OBJECT) { return false; } JsonObject coordinates = (JsonObject) c; if (!"Point".equals(coordinates.getString("type"))){ return false; } JsonArray a = coordinates.getJsonArray("coordinates"); assert a.size() == 2; double lon = a.getJsonNumber(0).doubleValue(); double lat = a.getJsonNumber(1).doubleValue(); for (BRect r : square) { if (lon < r.minLon || lon > r.maxLon) continue; if (lat >= r.minLat || lat <= r.maxLat) return true; } return false; } StrictLocationFilter(TwitterCollectionTask task); @Override boolean test(JsonObject t); @Override String getFilterName(); }
StrictLocationFilter implements Predicate<JsonObject> { @Override public boolean test(JsonObject t) { JsonValue c = t.get("coordinates"); if (c.getValueType() != ValueType.OBJECT) { return false; } JsonObject coordinates = (JsonObject) c; if (!"Point".equals(coordinates.getString("type"))){ return false; } JsonArray a = coordinates.getJsonArray("coordinates"); assert a.size() == 2; double lon = a.getJsonNumber(0).doubleValue(); double lat = a.getJsonNumber(1).doubleValue(); for (BRect r : square) { if (lon < r.minLon || lon > r.maxLon) continue; if (lat >= r.minLat || lat <= r.maxLat) return true; } return false; } StrictLocationFilter(TwitterCollectionTask task); @Override boolean test(JsonObject t); @Override String getFilterName();  }