Changeset 33051 in osm for applications/editors/josm/plugins/opendata
- Timestamp:
- 2016-11-11T23:40:04+01:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/opendata
- Files:
-
- 3 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReader.java
r32545 r33051 6 6 import java.io.InputStream; 7 7 import java.io.InputStreamReader; 8 import java.util.ArrayList;9 8 import java.util.HashMap; 10 import java.util.List;11 9 import java.util.Map; 12 10 … … 151 149 private void parseFeatureMember(Component parent) throws XMLStreamException, GeoCrsException, FactoryException, 152 150 UserCancelException, GeoMathTransformException, MismatchedDimensionException, TransformException { 153 List<OsmPrimitive> list = new ArrayList<>();154 151 Way way = null; 155 152 Node node = null; 156 Map<String, String> tags = new HashMap<>(); 153 Map<String, StringBuilder> tags = new HashMap<>(); 154 OsmPrimitive prim = null; 155 String key = null; 157 156 while (parser.hasNext()) { 158 157 int event = parser.next(); 159 158 if (event == XMLStreamConstants.START_ELEMENT) { 160 159 if (isElement(GML_LINE_STRING)) { 161 list.add(way = createWay());160 prim = way = createWay(); 162 161 parseSrs(parent); 163 162 } else if (isElement(GML_LINEAR_RING)) { 164 list.add(way = createWay());163 prim = way = createWay(); 165 164 } else if (isElement(GML_POINT)) { 166 165 parseSrs(parent); … … 174 173 if (way != null) { 175 174 way.addNode(node); 175 } else { 176 prim = node; 176 177 } 177 178 } … … 179 180 String[] tab = parser.getElementText().trim().split(","); 180 181 Point p = geometryFactory.createPoint(new Coordinate(Double.valueOf(tab[0]), Double.valueOf(tab[1]))); 181 list.add(node = createOrGetNode(p)); 182 node = createOrGetNode(p); 183 if (way == null) { 184 prim = node; 185 } 186 } else { 187 key = parser.getLocalName(); 188 if (key.startsWith("ogr:")) { 189 key = key.substring("ogr:".length()); 190 } 182 191 } 183 192 } else if (event == XMLStreamConstants.END_ELEMENT) { … … 185 194 break; 186 195 } 187 } 188 } 189 for (OsmPrimitive p : list) { 190 for (String key : tags.keySet()) { 191 p.put(key, tags.get(key)); 196 } else if (event == XMLStreamConstants.CHARACTERS && key != null) { 197 StringBuilder sb = tags.get(key); 198 if (sb == null) { 199 sb = new StringBuilder(); 200 tags.put(key, sb); 201 } 202 sb.append(parser.getTextCharacters(), parser.getTextStart(), parser.getTextLength()); 203 } 204 } 205 if (prim != null) { 206 for (String k : tags.keySet()) { 207 prim.put(k, tags.get(k).toString()); 192 208 } 193 209 }
Note:
See TracChangeset
for help on using the changeset viewer.