Changeset 30660 in osm for applications
- Timestamp:
- 2014-09-19T03:40:36+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/pbf/src/org/openstreetmap/josm/plugins/pbf/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pbf/src/org/openstreetmap/josm/plugins/pbf/io/PbfReader.java
r30341 r30660 13 13 import java.util.Map; 14 14 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.data.Bounds; 15 17 import org.openstreetmap.josm.data.coor.LatLon; 16 18 import org.openstreetmap.josm.data.osm.DataSet; 19 import org.openstreetmap.josm.data.osm.DataSource; 17 20 import org.openstreetmap.josm.data.osm.Node; 18 21 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 30 33 import crosby.binary.Osmformat; 31 34 import crosby.binary.Osmformat.DenseNodes; 35 import crosby.binary.Osmformat.HeaderBBox; 32 36 import crosby.binary.Osmformat.HeaderBlock; 33 37 import crosby.binary.Osmformat.Info; … … 45 49 public IllegalDataException exception = null; 46 50 51 private double parseRawDegrees(long raw) { 52 return raw * .000000001; 53 } 54 47 55 @Override 48 56 protected void parse(HeaderBlock header) { 57 58 for (String requiredFeature : header.getRequiredFeaturesList()) { 59 switch (requiredFeature) { 60 case "OsmSchema-V0.6": 61 ds.setVersion("0.6"); 62 break; 63 case "DenseNodes": 64 break; 65 default: 66 throw new UnsupportedOperationException("Unsupported feature: "+requiredFeature); 67 } 68 } 69 70 HeaderBBox bbox = header.getBbox(); 71 if (bbox != null) { 72 double minlat = parseRawDegrees(bbox.getBottom()); 73 double minlon = parseRawDegrees(bbox.getLeft()); 74 double maxlat = parseRawDegrees(bbox.getTop()); 75 double maxlon = parseRawDegrees(bbox.getRight()); 76 Bounds b = new Bounds(minlat, minlon, maxlat, maxlon); 77 if (!b.isCollapsed() && LatLon.isValidLat(minlat) && LatLon.isValidLat(maxlat) 78 && LatLon.isValidLon(minlon) && LatLon.isValidLon(maxlon)) { 79 ds.dataSources.add(new DataSource(b, header.getSource())); 80 } else { 81 Main.error("Invalid Bounds: "+b); 82 } 83 } 49 84 } 50 85 -
applications/editors/josm/plugins/pbf/src/org/openstreetmap/josm/plugins/pbf/io/PbfWriter.java
r30659 r30660 332 332 public void processSources(Collection<DataSource> sources) { 333 333 switchTypes(); 334 for (DataSource source: sources) { 335 processBounds(source); 334 // Can only write one bbox 335 if (!sources.isEmpty()) { 336 processBounds(sources.iterator().next()); 336 337 } 337 338 } … … 356 357 } 357 358 for (Node n : node) { 358 nodes.add(n); 359 checkLimit(); 359 if (n.getCoor() != null) { 360 nodes.add(n); 361 checkLimit(); 362 } 360 363 } 361 364 } … … 410 413 Osmformat.HeaderBBox.Builder bbox = Osmformat.HeaderBBox.newBuilder(); 411 414 bbox.setLeft(mapRawDegrees(entity.bounds.getMinLon())); 412 bbox.setBottom(mapRawDegrees(entity.bounds.getM axLat()));415 bbox.setBottom(mapRawDegrees(entity.bounds.getMinLat())); 413 416 bbox.setRight(mapRawDegrees(entity.bounds.getMaxLon())); 414 bbox.setTop(mapRawDegrees(entity.bounds.getM inLat()));417 bbox.setTop(mapRawDegrees(entity.bounds.getMaxLat())); 415 418 headerblock.setBbox(bbox); 416 419
Note:
See TracChangeset
for help on using the changeset viewer.