Changeset 9856 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/OverpassTurboQueryWizard.java
r9850 r9856 3 3 4 4 import java.io.IOException; 5 import java.io.InputStreamReader;6 5 import java.io.Reader; 7 import java.nio.charset.StandardCharsets;8 import java.util.HashMap;9 6 10 7 import javax.script.Invocable; … … 14 11 15 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.io.CachedFile; 16 14 17 15 /** … … 40 38 41 39 private OverpassTurboQueryWizard() { 42 try (final Reader reader = new InputStreamReader( 43 getClass().getResourceAsStream("/data/overpass-wizard.js"), StandardCharsets.UTF_8)) { 40 41 try (final CachedFile file = new CachedFile("resource://data/overpass-wizard.js"); 42 final Reader reader = file.getContentReader()) { 44 43 engine.eval("var console = {error: " + Main.class.getCanonicalName() + ".warn};"); 45 44 engine.eval("var global = {};"); 46 45 engine.eval(reader); 46 engine.eval("var overpassWizard = function(query) {" + 47 " return global.overpassWizard(query, {" + 48 " comment: false," + 49 " outputFormat: 'xml'," + 50 " outputMode: 'recursive_meta'" + 51 " });" + 52 "}"); 47 53 } catch (ScriptException | IOException ex) { 48 54 throw new RuntimeException("Failed to initialize OverpassTurboQueryWizard", ex); … … 58 64 public String constructQuery(String search) throws UncheckedParseException { 59 65 try { 60 final Object result = ((Invocable) engine).invokeMethod(engine.get("global"), 61 "overpassWizard", search, new HashMap<String, Object>() { { 62 put("comment", false); 63 put("outputFormat", "xml"); 64 put("outputMode", "recursive_meta"); 65 } } 66 ); 66 final Object result = ((Invocable) engine).invokeFunction("overpassWizard", search); 67 67 if (Boolean.FALSE.equals(result)) { 68 68 throw new UncheckedParseException(); -
trunk/test/unit/org/openstreetmap/josm/tools/OverpassTurboQueryWizardTest.java
r9815 r9856 5 5 6 6 import org.junit.BeforeClass; 7 import org.junit.Ignore;8 7 import org.junit.Test; 9 8 import org.openstreetmap.josm.JOSMFixture; … … 27 26 */ 28 27 @Test 29 @Ignore("see #12514 - Test does not work with Java 7, to enable after Java 8 migration if not fixed in the meantime")30 28 public void testKeyValue() { 31 29 final String query = OverpassTurboQueryWizard.getInstance().constructQuery("amenity=drinking_water");
Note:
See TracChangeset
for help on using the changeset viewer.