Changeset 1353 in josm for trunk/src/org/openstreetmap/josm/io/OsmReader.java
- Timestamp:
- 31.01.2009 19:09:46 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r1284 r1353 52 52 public class OsmReader { 53 53 54 static long tagsN = 0;55 static long nodesN = 0;56 static long waysN = 0;57 static long relationsN = 0;58 static long membersN = 0;54 // static long tagsN = 0; 55 // static long nodesN = 0; 56 // static long waysN = 0; 57 // static long relationsN = 0; 58 // static long membersN = 0; 59 59 60 60 static InputStream currSource; … … 143 143 private OsmPrimitive current; 144 144 private String generator; 145 int n = 0;146 145 // int n = 0; 146 147 147 @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 148 148 try { 149 if(n%100000 == 0) {150 try {151 FileInputStream fis = (FileInputStream)currSource;152 FileChannel channel = fis.getChannel();153 double perc = (((double)channel.position()) / ((double)channel.size()) * 100.0);154 System.out.format(" " + (int)perc + "%%");155 }156 catch(java.lang.ClassCastException cce) {157 }158 catch(IOException e) {159 System.out.format("Error reading file position " + e);160 }161 }162 n++; 149 // if(n%100000 == 0) { 150 // try { 151 // FileInputStream fis = (FileInputStream)currSource; 152 // FileChannel channel = fis.getChannel(); 153 // double perc = (((double)channel.position()) / ((double)channel.size()) * 100.0); 154 // System.out.format(" " + (int)perc + "%%"); 155 // } 156 // catch(java.lang.ClassCastException cce) { 157 // } 158 // catch(IOException e) { 159 // System.out.format("Error reading file position " + e); 160 // } 161 // } 162 // n++; 163 163 164 164 if (qName.equals("osm")) { … … 213 213 214 214 } else if (qName.equals("node")) { 215 nodesN++;215 // nodesN++; 216 216 current = new Node(new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon"))); 217 217 readCommon(atts, current); 218 218 nodes.put(current.id, (Node)current); 219 219 } else if (qName.equals("way")) { 220 waysN++;220 // waysN++; 221 221 current = new OsmPrimitiveData(); 222 222 readCommon(atts, current); … … 234 234 235 235 } else if (qName.equals("relation")) { 236 relationsN++;236 // relationsN++; 237 237 current = new OsmPrimitiveData(); 238 238 readCommon(atts, current); 239 239 relations.put((OsmPrimitiveData)current, new LinkedList<RelationMemberData>()); 240 240 } else if (qName.equals("member")) { 241 membersN++;241 // membersN++; 242 242 Collection<RelationMemberData> list = relations.get(current); 243 243 if (list == null) … … 257 257 258 258 } else if (qName.equals("tag")) { 259 tagsN++;259 // tagsN++; 260 260 current.put(atts.getValue("k"), atts.getValue("v")); 261 261 } … … 439 439 for (Way wy : ds.ways) 440 440 hm.put(wy.id, wy); 441 441 442 442 // pass 2 - sort out members 443 443 for (Entry<OsmPrimitiveData, Collection<RelationMemberData>> e : relations.entrySet()) { … … 490 490 osm.references = ref == null ? new DataSet() : ref; 491 491 492 492 493 493 currSource = source; 494 494 495 495 // phase 1: Parse nodes and read in raw ways 496 496 InputSource inputSource = new InputSource(new InputStreamReader(source, "UTF-8")); 497 497 try { 498 498 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, osm.new Parser()); 499 } catch (ParserConfigurationException e1) {499 } catch (ParserConfigurationException e1) { 500 500 e1.printStackTrace(); // broken SAXException chaining 501 501 throw new SAXException(e1); 502 }503 502 } 503 504 504 Main.pleaseWaitDlg.currentAction.setText(tr("Prepare OSM data...")); 505 505 Main.pleaseWaitDlg.setIndeterminate(true); 506 506 507 System.out.println(""); 508 System.out.println("Parser finished: Tags " + tagsN + " Nodes " + nodesN + " Ways " + waysN + 509 " Relations " + relationsN + " Members " + membersN); 507 // System.out.println("Parser finished: Tags " + tagsN + " Nodes " + nodesN + " Ways " + waysN + 508 // " Relations " + relationsN + " Members " + membersN); 510 509 511 510 for (Node n : osm.nodes.values()) … … 525 524 o.id = 0; 526 525 527 System.out.println("Data loaded!");526 // System.out.println("Data loaded!"); 528 527 Main.pleaseWaitDlg.setIndeterminate(false); 529 528 Main.pleaseWaitDlg.progress.setValue(0); 530 529 531 530 return osm; 532 531 }
Note: See TracChangeset
for help on using the changeset viewer.
