Changeset 14219 in josm
- Timestamp:
- 2018-09-02T21:53:46+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r14215 r14219 471 471 rememberErrorMessage(tr("No data found in this area.")); 472 472 } 473 String remark = dataSet.getRemark(); 474 if (remark != null && !remark.isEmpty()) { 475 rememberErrorMessage(remark); 476 } 473 477 // need to synthesize a download bounds lest the visual indication of downloaded area doesn't work 474 478 dataSet.addDataSource(new DataSource(currentBounds != null ? currentBounds : -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r14206 r14219 169 169 170 170 private short mappaintCacheIdx = 1; 171 private String remark; 171 172 172 173 /** … … 1231 1232 } 1232 1233 } 1234 1235 /** 1236 * Returns an optional remark about this data set (used by Overpass API). 1237 * @return a remark about this data set, or {@code null} 1238 * @since 14219 1239 */ 1240 public String getRemark() { 1241 return remark; 1242 } 1243 1244 /** 1245 * Sets an optional remark about this data set (used by Overpass API). 1246 * @param remark a remark about this data set, or {@code null} 1247 * @since 14219 1248 */ 1249 public void setRemark(String remark) { 1250 this.remark = remark; 1251 } 1233 1252 } -
trunk/src/org/openstreetmap/josm/io/OsmJsonReader.java
r14108 r14219 67 67 parseLocked(object.getString("locked", null)); 68 68 parseElements(object.getJsonArray("elements")); 69 parseRemark(object.getString("remark", null)); 70 } 71 72 private void parseRemark(String remark) { 73 ds.setRemark(remark); 69 74 } 70 75 -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r14094 r14219 103 103 uploadChangesetId = getLong("upload-changeset"); 104 104 } 105 while ( true) {105 while (parser.hasNext()) { 106 106 int event = parser.next(); 107 107 … … 127 127 case "changeset": 128 128 parseChangeset(uploadChangesetId); 129 break; 130 case "remark": // Used by Overpass API 131 parseRemark(); 129 132 break; 130 133 default: … … 143 146 } else { 144 147 throwException(e); 148 } 149 } 150 151 private void parseRemark() throws XMLStreamException { 152 while (parser.hasNext()) { 153 int event = parser.next(); 154 if (event == XMLStreamConstants.CHARACTERS) { 155 ds.setRemark(parser.getText()); 156 } else if (event == XMLStreamConstants.END_ELEMENT) { 157 return; 158 } 145 159 } 146 160 } -
trunk/test/unit/org/openstreetmap/josm/io/OsmJsonReaderTest.java
r14201 r14219 53 53 */ 54 54 private static DataSet parse(String osm) throws Exception { 55 return parse(osm, ""); 56 } 57 58 /** 59 * Parse JSON. 60 * @param osm OSM data in JSON format, without header/footer 61 * @param extraContent extra content added after OSM elements 62 * @return data set 63 * @throws Exception if any error occurs 64 */ 65 private static DataSet parse(String osm, String extraContent) throws Exception { 55 66 try (InputStream in = new ByteArrayInputStream(( 56 67 "{\n" + … … 65 76 " },\n" + 66 77 " \"elements\": [" + osm + "]\n" + 78 extraContent + 67 79 "}") 68 80 .getBytes(StandardCharsets.UTF_8))) { … … 225 237 assertEquals("route", r.get("type")); 226 238 } 239 240 /** 241 * Test reading remark from Overpass API. 242 * @throws Exception if any error occurs 243 */ 244 @Test 245 public void testRemark() throws Exception { 246 DataSet ds = parse("", "," + 247 " \"remark\": \"runtime error: Query ran out of memory in \\\"query\\\" at line 5.\"\n"); 248 assertEquals("runtime error: Query ran out of memory in \"query\" at line 5.", ds.getRemark()); 249 } 227 250 } -
trunk/test/unit/org/openstreetmap/josm/io/OsmReaderTest.java
r14078 r14219 115 115 * Test valid data. 116 116 * @param osm OSM data without XML prefix 117 * @throws Exception if any error occurs 118 */ 119 private static void testValidData(String osm) throws Exception { 117 * @return parsed data set 118 * @throws Exception if any error occurs 119 */ 120 private static DataSet testValidData(String osm) throws Exception { 120 121 try (InputStream in = new ByteArrayInputStream( 121 122 ("<?xml version='1.0' encoding='UTF-8'?>" + osm).getBytes(StandardCharsets.UTF_8))) { 122 OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);123 return OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE); 123 124 } 124 125 } … … 341 342 } 342 343 } 344 345 /** 346 * Test reading remark from Overpass API. 347 * @throws Exception if any error occurs 348 */ 349 @Test 350 public void testRemark() throws Exception { 351 DataSet ds = testValidData( 352 "<osm version=\"0.6\" generator=\"Overpass API 0.7.55.4 3079d8ea\">\r\n" + 353 "<note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>\r\n" + 354 "<meta osm_base=\"2018-08-30T12:46:02Z\" areas=\"2018-08-30T12:40:02Z\"/>\r\n" + 355 "<remark>runtime error: Query ran out of memory in \"query\" at line 5.</remark>\r\n" + 356 "</osm>"); 357 assertEquals("runtime error: Query ran out of memory in \"query\" at line 5.", ds.getRemark()); 358 } 343 359 }
Note:
See TracChangeset
for help on using the changeset viewer.