Changeset 33626 in osm for applications/editors
- Timestamp:
- 2017-09-18T06:27:29+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/wikipedia
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikosmDownloadSource.java
r33624 r33626 221 221 * is not restricted to bbox. 222 222 */ 223 if (!settings.getDownloadBounds().isPresent() && query.contains("{{bbox}}")) { 223 if (!settings.getDownloadBounds().isPresent() && ( 224 query.contains("{{boxParams}}") || 225 query.contains("{{center}}") 226 )) { 224 227 JOptionPane.showMessageDialog( 225 228 this.getParent(), -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/io/WikosmDownloadReader.java
r33624 r33626 88 88 protected String getRequestForBbox(double lon1, double lat1, double lon2, double lat2) { 89 89 final String query = this.wikosmQuery 90 .replace("{{boxParams}}", b box(lon1, lat1, lon2, lat2))90 .replace("{{boxParams}}", boxParams(lon1, lat1, lon2, lat2)) 91 91 .replace("{{center}}", center(lon1, lat1, lon2, lat2)); 92 92 return DATA_PREFIX + Utils.encodeUrl(query); 93 93 } 94 94 95 p rivate static String bbox(double lon1, double lat1, double lon2, double lat2) {96 return "\nbd:serviceParam wikibase:cornerWest " + point(lon1, lat1) + ". " +95 public static String boxParams(double lon1, double lat1, double lon2, double lat2) { 96 return "\nbd:serviceParam wikibase:cornerWest " + point(lon1, lat1) + ".\n" + 97 97 "bd:serviceParam wikibase:cornerEast " + point(lon2, lat2) + ".\n"; 98 98 } 99 99 100 p rivatestatic String center(double lon1, double lat1, double lon2, double lat2) {100 public static String center(double lon1, double lat1, double lon2, double lat2) { 101 101 LatLon c = new BBox(lon1, lat1, lon2, lat2).getCenter(); 102 102 return point(c.lon(), c.lat()); 103 103 } 104 104 105 p rivatestatic String point(double lon, double lat) {106 return " Point(\"" + lon + " " + lat + "\")^^geo:wktLiteral";105 public static String point(double lon, double lat) { 106 return "\"Point(" + lon + " " + lat + ")\"^^geo:wktLiteral"; 107 107 } 108 108 … … 266 266 267 267 // add bounds if necessary (note that Wikosm API does not return bounds in the response XML) 268 if (ds != null && ds.getDataSources().isEmpty() && wikosmQuery.contains("{{b box}}")) {268 if (ds != null && ds.getDataSources().isEmpty() && wikosmQuery.contains("{{boxParams}}")) { 269 269 if (crosses180th) { 270 270 Bounds bounds = new Bounds(lat1, lon1, lat2, 180.0); -
applications/editors/josm/plugins/wikipedia/test/unit/org/wikipedia/io/WikosmDownloadReaderTest.java
r33622 r33626 17 17 import java.util.List; 18 18 19 import static org.hamcrest.CoreMatchers.equalTo; 19 20 import static org.hamcrest.CoreMatchers.is; 20 21 import static org.junit.Assert.assertThat; … … 33 34 34 35 /** 35 * Tests evaluating the extended query feature {@code date}. 36 * Tests point generation 37 */ 38 @Test 39 public void testPoint() throws UnsupportedEncodingException { 40 assertThat(WikosmDownloadReader.point(9.5, 47.16), 41 is("\"Point(9.5 47.16)\"^^geo:wktLiteral")); 42 assertThat(WikosmDownloadReader.boxParams(1, 2, 3, 4), 43 is("\nbd:serviceParam wikibase:cornerWest \"Point(1 2)\"^^geo:wktLiteral." + 44 "\nbd:serviceParam wikibase:cornerEast \"Point(3 4)\"^^geo:wktLiteral.\n")); 45 } 46 47 /** 48 * Tests server response parsing 36 49 */ 37 50 @Test
Note:
See TracChangeset
for help on using the changeset viewer.