- Timestamp:
- 2016-02-23T13:29:54+01:00 (9 years ago)
- File:
-
- 1 edited
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();
Note:
See TracChangeset
for help on using the changeset viewer.