Changeset 17 in josm for src/org/openstreetmap/josm/io/GpxReader.java
- Timestamp:
- 2005-10-09T04:14:40+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/io/GpxReader.java
r16 r17 40 40 */ 41 41 public Reader source; 42 /** 43 * If <code>true</code>, only nodes and tracks are imported (but no key/value 44 * pairs). That is to support background gps information as an hint for 45 * real OSM data. 46 */ 47 private final boolean rawGps; 42 48 43 49 /** 44 50 * Construct a parser from a specific data source. 45 51 * @param source The data source, as example a FileReader to read from a file. 46 */ 47 public GpxReader(Reader source) { 52 * @param rawGps Whether the gpx file describes raw gps data. Only very few 53 * information (only nodes and line segments) imported for raw gps to 54 * save memory. 55 */ 56 public GpxReader(Reader source, boolean rawGps) { 48 57 this.source = source; 58 this.rawGps = rawGps; 49 59 } 50 60 … … 56 66 final SAXBuilder builder = new SAXBuilder(); 57 67 Element root = builder.build(source).getRootElement(); 58 System.out.println(root.getNamespacePrefix());59 68 60 69 // HACK, since the osm server seem to not provide a namespace. … … 85 94 Float.parseFloat(e.getAttributeValue("lat")), 86 95 Float.parseFloat(e.getAttributeValue("lon"))); 96 97 if (rawGps) 98 return data; 99 87 100 for (Object o : e.getChildren()) { 88 101 Element child = (Element)o; … … 126 139 for (Object o : e.getChildren()) { 127 140 Element child = (Element)o; 128 if (child.getName().equals("extensions")) 129 parseKeyValueExtensions(track, child); 130 else if (child.getName().equals("link")) 131 parseKeyValueLink(track, child); 132 else if (child.getName().equals("trkseg")) { 141 142 if (child.getName().equals("trkseg")) { 133 143 Node start = null; 134 144 for (Object w : child.getChildren("trkpt", GPX)) { … … 139 149 else { 140 150 LineSegment lineSegment = new LineSegment(start, node); 141 parseKeyValueExtensions(lineSegment, ((Element)w).getChild("extensions", GPX)); 151 if (!rawGps) 152 parseKeyValueExtensions(lineSegment, ((Element)w).getChild("extensions", GPX)); 142 153 track.add(lineSegment); 143 154 start = null; 144 155 } 145 156 } 146 } else 157 } 158 159 if (rawGps) 160 continue; 161 162 if (child.getName().equals("extensions")) 163 parseKeyValueExtensions(track, child); 164 else if (child.getName().equals("link")) 165 parseKeyValueLink(track, child); 166 else 147 167 parseKeyValueTag(track, child); 148 168 } … … 156 176 * to the node in the list (either the new added or the old found). 157 177 * 178 * If reading raw gps data, mergeNodes are always on (To save memory. You 179 * can't edit raw gps nodes anyway.) 180 * 158 181 * @param data The DataSet to add the node to. 159 182 * @param node The node that should be added. … … 161 184 */ 162 185 private Node addNode (DataSet data, Node node) { 163 if (Main.pref.mergeNodes )186 if (Main.pref.mergeNodes || rawGps) 164 187 for (Node n : data.nodes) 165 if (node.coor. lat == n.coor.lat && node.coor.lon == n.coor.lon)188 if (node.coor.equalsLatLon(n.coor)) 166 189 return n; 167 190 data.nodes.add(node);
Note:
See TracChangeset
for help on using the changeset viewer.