private void applySeparator() { if (separateNext) { builder.append("; "); } separateNext = false; }
/** * Adds a <i>(around:radius)</i> around radius filter to the current query. * * @param radius in meters around a predecessor input node * @return the current query object */ public OverpassFilterQuery around(double radius) { builder.around(radius); return this; }
/** * Adds a <i>(southernLat,westernLon,northernLat,easternLon)</i> bounding box filter to the current query. * * @param southernLat the southern latitude * @param westernLon the western longitude * @param northernLat the northern latitude * @param easternLon the eastern longitude * * @return the current query object */ public OverpassFilterQuery boundingBox(double southernLat, double westernLon, double northernLat, double easternLon) { builder.boundingBox(southernLat, westernLon, northernLat, easternLon); return this; }
@Test public void testClause() throws Exception { queryBuilder.standaloneParam("foo"); assertEquals("[\"foo\"]", queryBuilder.build()); }
@Test public void testBoundingBox() throws Exception { queryBuilder.boundingBox(1.01d, 2.002d, 3.003d, 4.0004d); assertEquals("(1.01,2.002,3.003,4.0004)", queryBuilder.build()); }
@Test public void testRegexMatches() throws Exception { queryBuilder.regexMatches("foo", "bar"); assertEquals("[\"foo\"~\"bar\"]", queryBuilder.build()); }
@Test public void testRegexDoesntMatch() throws Exception { queryBuilder.regexDoesntMatch("foo", "bar"); assertEquals("[\"foo\"!~\"bar\"]", queryBuilder.build()); } }
@Test public void testMultipleValues() throws Exception { queryBuilder.multipleValues("foo", new HashSet<>(Arrays.asList("bar", "baz"))); // It's a set! Order of elements are not guaranteed to be the same assertThat(queryBuilder.build(), anyOf( equalTo("[\"foo\"~\"bar|baz\"]"), equalTo("[\"foo\"~\"baz|bar\"]")) ); }
/** * Adds a <i>["name"=value]</i> filter tag to the current query. * * @param name the filter name * @param value the filter value * * @return the current query object */ public OverpassFilterQuery tag(String name, String value) { builder.equals(name, value); return this; }
/** * Adds a <i>["name"~{value1}|{value2}|{value3}|...|{valueN}]</i> filter tag to the current query * to add a filter matching for any of the given values. * * @param name the filter name * @param values the filter value * * @return the current query object */ public OverpassFilterQuery tagMultiple(String name, Set<String> values) { builder.multipleValues(name, values); return this; }
/** * Sets the maximum allowed runtime for the query in seconds. * * @see <a href="http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#timeout"> * http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#timeout</a> * * @param timeout the maximum allowed runtime in seconds * * @return the current OverpassQuery object */ public OverpassQuery timeout(int timeout) { builder.setting("timeout", "" + timeout); return this; }
/** * Adds a <i>["name"!~value]</i> filter tag to the current query. * * @param name the filter name * @param value the filter value * * @return the current query object */ public OverpassFilterQuery tagRegexNot(String name, String value) { builder.regexDoesntMatch(name, value); return this; }
/** * Adds a <i>["name"~value]</i> filter tag to the current query. * * @param name the filter name * @param value the filter value * * @return the current query object */ public OverpassFilterQuery tagRegex(String name, String value) { builder.regexMatches(name, value); return this; }
/** * Adds a <i>["name"!=value]</i> filter tag to the current query. * * @param name the filter name * @param value the filter value * * @return the current query object */ public OverpassFilterQuery tagNot(String name, String value) { builder.notEquals(name, value); return this; }
@Test public void testBuild() throws Exception { final String s = queryBuilder.build(); assertEquals("", s); }