Changeset 2115 in josm for trunk/src/org/openstreetmap/josm/io/OsmReader.java
- Timestamp:
- 2009-09-13T19:30:36+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r2094 r2115 36 36 37 37 /** 38 * Parser for the Osm Api. Read from an input stream and construct sa dataset out of it.38 * Parser for the Osm Api. Read from an input stream and construct a dataset out of it. 39 39 * 40 40 */ … … 80 80 } 81 81 82 private static class OsmPrimitiveData { 83 public long id = 0; 84 public boolean modified = false; 85 public boolean deleted = false; 86 public Date timestamp = new Date(); 87 public User user = null; 88 public boolean visible = true; 89 public int version = 0; 90 public LatLon latlon = new LatLon(0,0); 91 private OsmPrimitive primitive; 92 93 public void copyTo(OsmPrimitive osm) { 94 osm.setModified(modified); 95 osm.setDeleted(deleted); 96 // id < 0 possible if read from a file 97 if (id <= 0) { 98 osm.clearOsmId(); 99 } else { 100 osm.setOsmId(id, version); 101 } 102 osm.setTimestamp(timestamp); 103 osm.user = user; 104 osm.setVisible(visible); 105 osm.mappaintStyle = null; 106 } 107 108 public Node createNode() { 109 Node node = new Node(); 110 node.setCoor(latlon); 111 copyTo(node); 112 primitive = node; 113 return node; 114 } 115 116 public Way createWay() { 117 Way way = new Way(); 118 copyTo(way); 119 primitive = way; 120 return way; 121 } 122 public Relation createRelation() { 123 Relation relation= new Relation(); 124 copyTo(relation); 125 primitive = relation; 126 return relation; 127 } 128 129 public void rememberTag(String key, String value) { 130 primitive.put(key, value); 131 } 132 } 82 133 83 134 /** … … 100 151 */ 101 152 private Map<Long, Collection<RelationMemberData>> relations = new HashMap<Long, Collection<RelationMemberData>>(); 102 103 153 104 154 private class Parser extends DefaultHandler { … … 241 291 current.rememberTag(key, value); 242 292 } else { 243 System.out.println(tr("Warning:Undefined element ''{0}'' found in input stream.Skipping.", qName));293 throwException(tr("Undefined element ''{0}'' found in input stream. Aborting.", qName)); 244 294 } 245 295 } … … 503 553 } 504 554 } 505 506 /**507 * Temporarily holds data for a parsed {@see OsmPrimitive} and provides508 * methods for creating an {@see OsmPrimitive} based on this data.509 */510 private static class OsmPrimitiveData {511 public long id = 0;512 public boolean modified = false;513 public boolean deleted = false;514 public Date timestamp = new Date();515 public User user = null;516 public boolean visible = true;517 public int version = 0;518 public LatLon latlon = new LatLon(0,0);519 private OsmPrimitive primitive;520 521 public void copyTo(OsmPrimitive osm) {522 // id < 0 possible if read from a file523 if (id <= 0) {524 osm.clearOsmId();525 } else {526 osm.setOsmId(id, version);527 }528 osm.setDeleted(deleted);529 osm.setModified(modified);530 osm.setTimestamp(timestamp);531 osm.user = user;532 osm.setVisible(visible);533 osm.mappaintStyle = null;534 }535 536 public Node createNode() {537 Node node = new Node();538 node.setCoor(latlon);539 copyTo(node);540 primitive = node;541 return node;542 }543 544 public Way createWay() {545 Way way = new Way();546 copyTo(way);547 primitive = way;548 return way;549 }550 public Relation createRelation() {551 Relation relation= new Relation();552 copyTo(relation);553 primitive = relation;554 return relation;555 }556 557 public void rememberTag(String key, String value) {558 primitive.put(key, value);559 }560 }561 555 }
Note:
See TracChangeset
for help on using the changeset viewer.
