Ticket #20037: 20037.patch
| File 20037.patch, 2.5 KB (added by , 5 years ago) |
|---|
-
src/org/openstreetmap/josm/tools/SearchCompilerQueryWizard.java
15 15 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 17 17 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 18 import org.openstreetmap.josm.data.osm.search.SearchCompiler.ExactKeyValue.Mode; 18 19 import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match; 19 20 import org.openstreetmap.josm.data.osm.search.SearchParseError; 20 21 … … 73 74 throw new IllegalStateException(mode); 74 75 } 75 76 } 76 77 77 78 final Match match = SearchCompiler.compile(search); 78 79 return constructQuery(match, "[bbox:{{bbox}}];", ""); 79 80 } catch (SearchParseError | UnsupportedOperationException e) { … … 129 130 // [~"key"~"value", i] -- filter objects tagged with a key and a case-insensitive value matching regular expressions 130 131 final String key = ((SearchCompiler.ExactKeyValue) match).getKey(); 131 132 final String value = ((SearchCompiler.ExactKeyValue) match).getValue(); 132 final SearchCompiler.ExactKeyValue.Mode mode = ((SearchCompiler.ExactKeyValue) match).getMode();133 final Mode mode = ((SearchCompiler.ExactKeyValue) match).getMode(); 133 134 switch (mode) { 134 135 case ANY_VALUE: 135 136 return "[" + (negated ? "!" : "") + quote(key) + "]"; … … 136 137 case EXACT: 137 138 return "[" + quote(key) + (negated ? "!=" : "=") + quote(value) + "]"; 138 139 case EXACT_REGEXP: 140 case ANY_KEY: // *=value 139 141 final Matcher matcher = Pattern.compile("/(?<regex>.*)/(?<flags>i)?").matcher(value); 140 142 final String valueQuery = matcher.matches() 141 143 ? quote(matcher.group("regex")) + Optional.ofNullable(matcher.group("flags")).map(f -> "," + f).orElse("") 142 144 : quote(value); 145 if (mode == Mode.ANY_KEY) 146 return "[~\"^.*$\"" + (negated ? "!~" : "~") + valueQuery + "]"; 143 147 return "[" + quote(key) + (negated ? "!~" : "~") + valueQuery + "]"; 144 148 case MISSING_KEY: 145 149 // special case for empty values, see https://github.com/drolbr/Overpass-API/issues/53
