Ignore:
Timestamp:
31.01.2009 19:09:46 (3 years ago)
Author:
stoecker
Message:

apply patch by xeen - #2114

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r1284 r1353  
    5252public class OsmReader { 
    5353 
    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; 
    5959 
    6060     static InputStream currSource; 
     
    143143          private OsmPrimitive current; 
    144144          private String generator; 
    145           int n = 0; 
    146            
     145//          int n = 0; 
     146 
    147147          @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 
    148148               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++; 
    163163 
    164164                    if (qName.equals("osm")) { 
     
    213213 
    214214                    } else if (qName.equals("node")) { 
    215                          nodesN++; 
     215//                         nodesN++; 
    216216                         current = new Node(new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon"))); 
    217217                         readCommon(atts, current); 
    218218                         nodes.put(current.id, (Node)current); 
    219219                    } else if (qName.equals("way")) { 
    220                          waysN++; 
     220//                         waysN++; 
    221221                         current = new OsmPrimitiveData(); 
    222222                         readCommon(atts, current); 
     
    234234 
    235235                    } else if (qName.equals("relation")) { 
    236                          relationsN++; 
     236//                         relationsN++; 
    237237                         current = new OsmPrimitiveData(); 
    238238                         readCommon(atts, current); 
    239239                         relations.put((OsmPrimitiveData)current, new LinkedList<RelationMemberData>()); 
    240240                    } else if (qName.equals("member")) { 
    241                          membersN++; 
     241//                         membersN++; 
    242242                         Collection<RelationMemberData> list = relations.get(current); 
    243243                         if (list == null) 
     
    257257 
    258258                    } else if (qName.equals("tag")) { 
    259                          tagsN++; 
     259//                         tagsN++; 
    260260                         current.put(atts.getValue("k"), atts.getValue("v")); 
    261261                    } 
     
    439439          for (Way wy : ds.ways) 
    440440            hm.put(wy.id, wy); 
    441            
     441 
    442442          // pass 2 - sort out members 
    443443          for (Entry<OsmPrimitiveData, Collection<RelationMemberData>> e : relations.entrySet()) { 
     
    490490          osm.references = ref == null ? new DataSet() : ref; 
    491491 
    492            
     492 
    493493          currSource = source; 
    494            
     494 
    495495          // phase 1: Parse nodes and read in raw ways 
    496496          InputSource inputSource = new InputSource(new InputStreamReader(source, "UTF-8")); 
    497497          try { 
    498498             SAXParserFactory.newInstance().newSAXParser().parse(inputSource, osm.new Parser()); 
    499         } catch (ParserConfigurationException e1) { 
     499          } catch (ParserConfigurationException e1) { 
    500500             e1.printStackTrace(); // broken SAXException chaining 
    501501             throw new SAXException(e1); 
    502         } 
    503              
     502          } 
     503 
    504504          Main.pleaseWaitDlg.currentAction.setText(tr("Prepare OSM data...")); 
    505505          Main.pleaseWaitDlg.setIndeterminate(true);  
    506506 
    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); 
    510509 
    511510          for (Node n : osm.nodes.values()) 
     
    525524                    o.id = 0; 
    526525 
    527           System.out.println("Data loaded!"); 
     526//          System.out.println("Data loaded!"); 
    528527          Main.pleaseWaitDlg.setIndeterminate(false);  
    529528          Main.pleaseWaitDlg.progress.setValue(0);  
    530            
     529 
    531530          return osm; 
    532531     } 
Note: See TracChangeset for help on using the changeset viewer.