Changeset 32857 in osm for applications/editors/josm/plugins/o5m/src/org
- Timestamp:
- 2016-08-21T07:42:12+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/io/O5mReader.java
r32833 r32857 28 28 import java.util.Map; 29 29 30 import org.openstreetmap.josm.Main; 31 import org.openstreetmap.josm.data.Bounds; 32 import org.openstreetmap.josm.data.DataSource; 30 33 import org.openstreetmap.josm.data.coor.LatLon; 31 34 import org.openstreetmap.josm.data.osm.DataSet; … … 50 53 public class O5mReader extends AbstractReader { 51 54 public IllegalDataException exception = null; 52 55 private boolean discourageUpload; 56 53 57 private static void checkCoordinates(LatLon coor) throws IllegalDataException { 54 58 if (!coor.isValid()) { … … 115 119 private int version; 116 120 private User osmUser; 117 121 private String header; 118 122 /** 119 123 * A parser for the o5m format 120 * @param processor A mapProcessor instance121 124 * @param stream The InputStream that contains the OSM data in o5m format 122 * @param skipArray An Array of longs that is used to hold information of file position of the first occurrence of123 * each known 05m data type (esp. nodes, ways, and relations).124 125 */ 125 126 O5mReader(InputStream stream) { … … 144 145 throw new IOException(tr("wrong header byte ") + Integer.toHexString(start)); 145 146 readFile(); 147 if (discourageUpload) 148 ds.setUploadDiscouraged(true); 146 149 } catch (IOException e) { 147 150 e.printStackTrace(); … … 189 192 else if (fileType == WAY_DATASET) readWay(); 190 193 else if (fileType == REL_DATASET) readRel(); 191 //else if (fileType == BBOX_DATASET) readBBox();194 else if (fileType == BBOX_DATASET) readBBox(); 192 195 else if (fileType == TIMESTAMP_DATASET) readFileTimestamp(); 193 196 else if (fileType == HEADER_DATASET) readHeader(); … … 222 225 * @throws IOException 223 226 */ 224 /*225 227 private void readBBox() { 226 double leftf = (double) (100L*readSignedNum32()) * FACTOR; 227 double bottomf = (double) (100L*readSignedNum32()) * FACTOR; 228 double rightf = (double) (100L*readSignedNum32()) * FACTOR; 229 double topf = (double) (100L*readSignedNum32()) * FACTOR; 230 assert bytesToRead == 0; 231 setBBox(bottomf, leftf, topf, rightf); 232 } 233 */ 228 double minlon = FACTOR * 100L * readSignedNum32(); 229 double minlat = FACTOR * 100L * readSignedNum32(); 230 double maxlon = FACTOR * 100L * readSignedNum32(); 231 double maxlat = FACTOR * 100L * readSignedNum32(); 232 233 Bounds b = new Bounds(minlat, minlon, maxlat, maxlon); 234 if (!b.isCollapsed() && LatLon.isValidLat(minlat) && LatLon.isValidLat(maxlat) 235 && LatLon.isValidLon(minlon) && LatLon.isValidLon(maxlon)) { 236 ds.dataSources.add(new DataSource(b, header)); 237 } else { 238 Main.error("Invalid Bounds: "+b); 239 } 240 } 234 241 235 242 /** … … 255 262 assert flat >= -90.0 && flat <= 90.0; 256 263 assert flon >= -180.0 && flon <= 180.0; 264 if (version == 0) 265 discourageUpload = true; 257 266 Node node = new Node(lastNodeId, version == 0 ? 1:version); 258 267 node.setCoor(new LatLon(flat, flon).getRoundedToOsmPrecision()); … … 295 304 if (bytesToRead == 0) 296 305 return; // only wayId + version: this is a delete action, we ignore it 306 if (version == 0) 307 discourageUpload = true; 297 308 final Way way = new Way(lastWayId, version == 0 ? 1:version); 298 309 checkChangesetId(lastChangeSet); … … 339 350 if (bytesToRead == 0) 340 351 return; // only relId + version: this is a delete action, we ignore it 352 if (version == 0) 353 discourageUpload = true; 341 354 final Relation rel = new Relation(lastRelId, version == 0 ? 1:version); 342 355 checkChangesetId(lastChangeSet); … … 565 578 throw new IOException(tr("unsupported header")); 566 579 } 580 header = new String(ioBuf, 0, 3, "UTF-8"); 567 581 } 568 582
Note:
See TracChangeset
for help on using the changeset viewer.