Changeset 31441 in osm for applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap
- Timestamp:
- 2015-08-03T20:15:28+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/core/TrainWorker.java
r31106 r31441 30 30 import java.util.logging.Logger; 31 31 import javax.swing.SwingWorker; 32 import org.opengis.referencing.FactoryException;33 32 import org.openstreetmap.josm.plugins.container.OSMRelation; 34 33 import org.openstreetmap.josm.plugins.container.OSMWay; … … 78 77 private static double foldScore10 = 0; 79 78 private static double bestScore = 0; 80 int trainProgress = 0;79 private int trainProgress = 0; 81 80 private final boolean validateFlag; 82 81 private final double cParameterFromUser; … … 87 86 private String textualListFilePath; 88 87 89 private static boolean USE_CLASS_FEATURES = false;90 private static boolean USE_RELATION_FEATURES = false;91 private static boolean USE_TEXTUAL_FEATURES = true;88 private static final boolean USE_CLASS_FEATURES = false; 89 private static final boolean USE_RELATION_FEATURES = false; 90 private static final boolean USE_TEXTUAL_FEATURES = true; 92 91 private static int numberOfFeatures; 93 92 private static LanguageDetector languageDetector; … … 173 172 if(topKIsSelected){ 174 173 textualList = anal.getTopKMostFrequent(topK); 175 System.out.println(textualList);174 //System.out.println(textualList); 176 175 } 177 176 else{ 178 177 textualList = anal.getWithFrequency(frequency); 179 System.out.println(textualList);178 //System.out.println(textualList); 180 179 } 181 180 … … 230 229 readTextualFromDefaultList(textualFileStream); 231 230 232 OSMParser osmParser = null; 233 try { 234 osmParser = new OSMParser(inputFilePath); 235 236 } catch (FactoryException ex) { 237 Logger.getLogger(TrainWorker.class.getName()).log(Level.SEVERE, null, ex); 238 } 231 OSMParser osmParser = new OSMParser(inputFilePath); 239 232 240 233 osmParser.parseDocument(); … … 354 347 355 348 if(way.getClassIDs().isEmpty()){ 356 wayListSizeWithoutUnclassified = wayListSizeWithoutUnclassified-1;349 wayListSizeWithoutUnclassified -= 1; 357 350 u++; 358 351 } … … 465 458 //System.out.println("file created"); 466 459 model.save(modelFile); 467 //System.out.println("saved");460 System.out.println("model saved at: " + modelFile); 468 461 } catch (IOException ex) { 469 462 Logger.getLogger(TrainWorker.class.getName()).log(Level.SEVERE, null, ex); … … 504 497 if(way.getClassIDs().isEmpty()){ 505 498 //System.out.println("found unclassified" + way.getClassIDs() + "class: " +way.getClassID()); 506 wayListSizeWithoutUnclassified2 = wayListSizeWithoutUnclassified2-1;499 wayListSizeWithoutUnclassified2 -= 1; 507 500 //u++; 508 501 } … … 614 607 615 608 System.out.println("Succeeded " + succededInstances + " of " + testList.size() + " total (1 class prediction)"); 616 double precision1 = (double)succededInstances/(double)wayListSizeWithoutUnclassified2;609 double precision1 = succededInstances/(double)wayListSizeWithoutUnclassified2; 617 610 score1 = precision1; 618 611 System.out.println(precision1); 619 612 620 613 System.out.println("Succeeded " + succededInstances5 + " of " + testList.size()+ " total (5 class prediction)"); 621 double precision5 = (double)succededInstances5/(double)wayListSizeWithoutUnclassified2;614 double precision5 = succededInstances5/(double)wayListSizeWithoutUnclassified2; 622 615 score5 = precision5; 623 616 System.out.println(precision5); 624 617 625 618 System.out.println("Succeeded " + succededInstances10 + " of " + testList.size()+ " total (10 class prediction)"); 626 double precision10 = (double)succededInstances10/(double)wayListSizeWithoutUnclassified2;619 double precision10 = succededInstances10/(double)wayListSizeWithoutUnclassified2; 627 620 score10 = precision10; 628 621 System.out.println(precision10); … … 651 644 652 645 if(way.getClassIDs().isEmpty()){ 653 wayListSizeWithoutUnclassified = wayListSizeWithoutUnclassified-1;646 wayListSizeWithoutUnclassified -= 1; 654 647 u++; 655 648 } … … 781 774 782 775 if(way.getClassIDs().isEmpty()){ 783 wayListSizeWithoutUnclassified = wayListSizeWithoutUnclassified-1;776 wayListSizeWithoutUnclassified -= 1; 784 777 u++; 785 778 } … … 888 881 //System.out.println("file created"); 889 882 model.save(modelFile); 890 //System.out.println("saved");883 System.out.println("model saved at: " + modelFile); 891 884 } catch (IOException ex) { 892 885 Logger.getLogger(TrainWorker.class.getName()).log(Level.SEVERE, null, ex); … … 932 925 writer.write(entry.getKey()); 933 926 writer.newLine(); 934 System.out.println(entry.getKey());927 //System.out.println(entry.getKey()); 935 928 } 936 929 } catch (UnsupportedEncodingException ex) { -
applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecPluginHelper.java
r31402 r31441 164 164 private static LanguageDetector languageDetector; 165 165 private static String bestModelPath; 166 private boolean modelWithClasses;// = false; 166 167 private final String modelWithClassesPath; 168 private boolean useCustomSVMModel = false; 169 private String customSVMModelPath; 167 170 168 171 … … 468 471 daysField = new javax.swing.JTextField(); 469 472 473 cParameterCheckBox.setSelected(true); 470 474 userHistoryPanel.setEnabled(false); 471 475 byAreaRadioButton.setEnabled(false); … … 490 494 inputFileErrorMessageLabel.setForeground(Color.RED); 491 495 inputFileErrorMessageLabel.setText(""); 496 topKField.setText("50"); 497 frequencyField.setText("200"); 498 cParameterField.setText("0.01"); 492 499 493 500 cParameterField.setColumns(FIELD_COLUMNS); … … 926 933 acceptConfigButton.setEnabled(true); 927 934 fileBrowseButton.setEnabled(true); 935 trainFromUserCheckBox.setEnabled(true); 928 936 929 937 if(trainFromUserCheckBox.isSelected()){ … … 967 975 968 976 try { 977 System.out.println("executing userDataExtractAndTrainWorker Thread.."); 969 978 userDataExtractAndTrainWorker.execute(); 970 979 } catch (Exception ex) { … … 1197 1206 private final JButton chooseModelButton; 1198 1207 private final JTextField chooseModelTextField; 1199 private final JList modelCombinationList;1200 private final DefaultListModel<String> combinationDefaultListModel = new DefaultListModel<>(); ;1208 private final JList<String> modelCombinationList; 1209 private final DefaultListModel<String> combinationDefaultListModel = new DefaultListModel<>(); 1201 1210 private final JPanel modelCombinationPanel; 1202 1211 //private final JTextField weightTextField; … … 1336 1345 System.out.println("\n\nUSE COMBINED MODEL\n\n"); 1337 1346 //recompute predictions with combination 1338 addDialog.loadSVMmodel(false); //maybe ask user about if the model contains classes 1347 modelWithClasses = false; 1348 addDialog.loadSVMmodel(); 1349 addDialog.createOSMObject(sel); 1339 1350 } 1340 1351 else { 1341 1352 useCombinedModel = false; 1353 addDialog.loadSVMmodel(); 1354 addDialog.createOSMObject(sel); 1342 1355 } 1343 1356 } … … 1351 1364 if(returnVal == JFileChooser.APPROVE_OPTION) { 1352 1365 chooseModelTextField.setText(fileChooser.getSelectedFile().getAbsolutePath()); 1353 } 1366 useCustomSVMModel = true; 1367 customSVMModelPath = fileChooser.getSelectedFile().getAbsolutePath(); 1368 } 1369 1354 1370 1355 1371 if(useModelCombinationCheckbox.isSelected()){ … … 1391 1407 weightPanelComponent.setEnabled(true); 1392 1408 } 1393 1409 useCustomSVMModel = false; //reseting the selected custom SVM model only here 1394 1410 } 1395 1411 else{ … … 1416 1432 1417 1433 weightValue = Math.abs(weightValue); 1418 weightSum = weightSum +weightValue;1434 weightSum += weightValue; 1419 1435 } 1420 1436 catch (NumberFormatException ex){ … … 1543 1559 if(s.getInterestingTags().isEmpty()){ 1544 1560 //load original model 1545 loadSVMmodel(false); 1546 createOSMObject(sel, false); //create object without class features 1561 modelWithClasses = false; 1562 loadSVMmodel(); 1563 createOSMObject(sel); //create object without class features 1547 1564 } 1548 1565 else{ … … 1550 1567 if(useTagsCheckBox.isSelected()){ 1551 1568 //load model with classes 1552 loadSVMmodel(true); 1553 createOSMObject(sel, true); //create object including class features 1569 modelWithClasses = true; 1570 loadSVMmodel(); 1571 createOSMObject(sel); //create object including class features 1554 1572 } 1555 1573 else{ 1556 loadSVMmodel(false); 1557 createOSMObject(sel, false); //create object including class features 1574 modelWithClasses = false; 1575 loadSVMmodel(); 1576 createOSMObject(sel); //create object including class features 1558 1577 } 1559 1578 } … … 1579 1598 if(s.getInterestingTags().isEmpty()){ 1580 1599 //load original model 1581 loadSVMmodel(false); 1582 createOSMObject(sel, false); //create object without class features 1600 modelWithClasses = false; 1601 loadSVMmodel(); 1602 createOSMObject(sel); //create object without class features 1583 1603 } 1584 1604 else{ … … 1586 1606 if(useTagsCheckBox.isSelected()){ 1587 1607 //load model with classes 1588 loadSVMmodel(true); 1589 createOSMObject(sel, true); //create object including class features 1608 modelWithClasses = true; 1609 loadSVMmodel(); 1610 createOSMObject(sel); //create object including class features 1590 1611 } 1591 1612 else{ 1592 loadSVMmodel(false); 1593 createOSMObject(sel, false); //create object including class features 1613 modelWithClasses = false; 1614 loadSVMmodel(); 1615 createOSMObject(sel); //create object including class features 1594 1616 } 1595 1617 } … … 1649 1671 File modelWithClassesFile = new File(modelWithClassesPath); 1650 1672 if(s.getInterestingTags().isEmpty() || !modelWithClassesFile.exists()){ 1651 loadSVMmodel(false);//load original model 1652 createOSMObject(sel, false); //create object without class features 1673 modelWithClasses = false; 1674 loadSVMmodel();//load original model 1675 createOSMObject(sel); //create object without class features 1653 1676 1654 1677 1655 1678 } 1656 1679 else{ 1657 loadSVMmodel(true);//load model with classes 1658 createOSMObject(sel, true); //create object including class features 1680 modelWithClasses = true; 1681 loadSVMmodel();//load model with classes 1682 createOSMObject(sel); //create object including class features 1659 1683 } 1660 1684 } … … 1938 1962 } 1939 1963 1940 private void loadSVMmodel( boolean modelWithClasses) {1964 private void loadSVMmodel() { 1941 1965 if(useCombinedModel){ 1942 1966 System.out.println("Using combined model."); … … 1948 1972 1949 1973 File modelFile; 1950 if(modelWithClasses){ 1951 modelFile = new File(modelDirectory.getAbsolutePath() + "/model_with_classes"); 1952 } 1953 else { 1954 modelFile = new File(modelDirectory.getAbsolutePath() + "/best_model"); 1955 } 1974 if(useCustomSVMModel){ 1975 System.out.println("using custom model: " + customSVMModelPath); 1976 modelFile = new File(customSVMModelPath); 1977 } 1978 else{ 1979 if(modelWithClasses){ 1980 System.out.println("using model with classes: " + modelDirectory.getAbsolutePath() + "/model_with_classes"); 1981 modelFile = new File(modelDirectory.getAbsolutePath() + "/model_with_classes"); 1982 } 1983 else { 1984 System.out.println("using best model: " + modelDirectory.getAbsolutePath() + "/best_model"); 1985 modelFile = new File(modelDirectory.getAbsolutePath() + "/best_model"); 1986 } 1987 } 1988 1956 1989 1957 1990 1958 1991 try { 1959 1992 modelSVM = Model.load(modelFile); 1960 System.out.println("model loaded: " + modelFile.getAbsolutePath());1993 //System.out.println("model loaded: " + modelFile.getAbsolutePath()); 1961 1994 } catch (IOException ex) { 1962 1995 Logger.getLogger(TrainWorker.class.getName()).log(Level.SEVERE, null, ex); … … 2233 2266 } 2234 2267 2235 private void createOSMObject(Collection<OsmPrimitive> sel , boolean useClassFeatures) {2268 private void createOSMObject(Collection<OsmPrimitive> sel) { 2236 2269 2237 2270 MathTransform transform = null; … … 2270 2303 for(Node node : selectedWayNodes){ 2271 2304 node.getCoor(); 2272 System.out.println(node.getCoor());2305 //System.out.println(node.getCoor()); 2273 2306 if(node.isLatLonKnown()){ 2274 2307 //LatLon coord = nod.getCoor(); … … 2339 2372 classifier.calculateClasses(selectedInstance, mappings, mapperWithIDs, indirectClasses, indirectClassesWithIDs); 2340 2373 2341 if( useClassFeatures){2374 if(modelWithClasses){ 2342 2375 ClassFeatures classFeatures = new ClassFeatures(); 2343 2376 classFeatures.createClassFeatures(selectedInstance, mappings, mapperWithIDs, indirectClasses, indirectClassesWithIDs); … … 2373 2406 2374 2407 mapLabelsToIDs.put(modelSVMLabels[h], h); 2375 System.out.println(h + " <-> " + modelSVMLabels[h]);2408 //System.out.println(h + " <-> " + modelSVMLabels[h]); 2376 2409 2377 2410 } -
applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/TrainByUser.java
r31106 r31441 8 8 import de.bwaldvogel.liblinear.Problem; 9 9 import de.bwaldvogel.liblinear.SolverType; 10 import java.awt.event.ActionEvent; 11 import java.awt.event.ActionListener; 10 12 import java.io.BufferedWriter; 11 13 import java.io.File; … … 24 26 import java.util.List; 25 27 import java.util.Map; 28 import java.util.concurrent.ExecutionException; 26 29 import java.util.logging.Level; 27 30 import java.util.logging.Logger; 31 import javax.swing.SwingWorker; 28 32 import org.openstreetmap.josm.plugins.container.OSMRelation; 29 33 import org.openstreetmap.josm.plugins.container.OSMWay; … … 45 49 */ 46 50 47 public class TrainByUser {51 public class TrainByUser extends SwingWorker<Void, Void> implements ActionListener{ 48 52 49 53 private final String inputFilePath; … … 67 71 private static double foldScore10 = 0; 68 72 private static double bestScore = 0; 69 int trainProgress = 0;73 //int trainProgress = 0; 70 74 private final boolean validateFlag; 71 75 private final double cParameterFromUser; … … 75 79 private final boolean topKIsSelected; 76 80 private String textualListFilePath; 77 private static boolean USE_CLASS_FEATURES = false;78 private static boolean USE_RELATION_FEATURES = false;79 private static boolean USE_TEXTUAL_FEATURES = true;81 private static final boolean USE_CLASS_FEATURES = false; 82 private static final boolean USE_RELATION_FEATURES = false; 83 private static final boolean USE_TEXTUAL_FEATURES = true; 80 84 private static int numberOfFeatures; 81 85 private static LanguageDetector languageDetector; … … 108 112 TrainByUser.wayList = wayList; 109 113 } 110 111 112 public void executeTraining(){114 115 @Override 116 public Void doInBackground() throws Exception { 113 117 extractTextualList(); 114 118 parseFiles(); 115 if(validateFlag){ 119 if(validateFlag){ 120 firePropertyChange("progress", getProgress(), 5); 121 //setProgress(5); 116 122 validateLoop(); 123 firePropertyChange("progress", getProgress(), 40); 124 //setProgress(40); 117 125 System.out.println("Training model with the best c: " + bestConfParam); 118 126 clearDataset(); 119 127 trainModel(bestConfParam); 128 firePropertyChange("progress", getProgress(), 60); 129 //setProgress(80); 120 130 clearDataset(); 121 131 trainModelWithClasses(bestConfParam); 122 132 firePropertyChange("progress", getProgress(), 100); 133 setProgress(100); 123 134 } 124 135 else{ 136 137 //firePropertyChange("progress", getProgress(), 5); 138 //setProgress(5); 125 139 clearDataset(); 140 firePropertyChange("progress", getProgress(), 10); 141 //setProgress(10); 126 142 trainModel(cParameterFromUser); 143 //setProgress(60); 144 firePropertyChange("progress", getProgress(), 60); 127 145 clearDataset(); 128 trainModelWithClasses(cParameterFromUser); 146 firePropertyChange("progress", getProgress(), 65); 147 //setProgress(65); 148 trainModelWithClasses(cParameterFromUser); 149 150 firePropertyChange("progress", getProgress(), 100); 151 setProgress(100); 129 152 System.out.println("done."); 130 153 } 131 System.out.println("Train by user process complete."); 154 System.out.println("Train by user process complete."); 155 return null; 132 156 } 133 157 … … 232 256 233 257 for(Double param : confParams){ 234 258 //setProgress(4*((5*(trainProgress++))/confParams.length)); 235 259 foldScore1 = 0; 236 260 foldScore5 = 0; … … 238 262 System.out.println("\n\n\nrunning for C = " + param); 239 263 clearDataset(); 240 System.out.println("fold1"); 264 System.out.println("fold1"); 241 265 //crossValidateFold(0, 3, 3, 4, false, param); 242 266 crossValidateFold(0, 4, 4, 5, false, param); //4-1 … … 294 318 295 319 } 296 System.out.println(4*((5*(trainProgress++))/confParams.length));320 //System.out.println(4*((5*(trainProgress++))/confParams.length)); 297 321 //setProgress(100); 298 322 bestConfParam = bestC; … … 319 343 //set classes for each osm instance 320 344 int sizeToBeAddedToArray = 0; //this will be used to proper init the features array, adding the multiple vectors size 321 int lalala = 0;322 345 for(OSMWay way : trainList){ 323 346 … … 326 349 327 350 if(way.getClassIDs().isEmpty()){ 328 wayListSizeWithoutUnclassified = wayListSizeWithoutUnclassified-1;351 wayListSizeWithoutUnclassified -= 1; 329 352 u++; 330 353 } … … 382 405 } 383 406 for(int classID : way.getClassIDs()){ 384 lalala++;385 407 trainingSetWithUnknown2[k] = featureNodeArray; 386 408 GROUPS_ARRAY2[k] = classID; … … 472 494 if(way.getClassIDs().isEmpty()){ 473 495 //System.out.println("found unclassified" + way.getClassIDs() + "class: " +way.getClassID()); 474 wayListSizeWithoutUnclassified2 = wayListSizeWithoutUnclassified2-1;496 wayListSizeWithoutUnclassified2 -= 1; 475 497 //u++; 476 498 } … … 582 604 583 605 System.out.println("Succeeded " + succededInstances + " of " + testList.size() + " total (1 class prediction)"); 584 double precision1 = (double)succededInstances/(double)wayListSizeWithoutUnclassified2;606 double precision1 = succededInstances/(double)wayListSizeWithoutUnclassified2; 585 607 score1 = precision1; 586 608 System.out.println(precision1); 587 609 588 610 System.out.println("Succeeded " + succededInstances5 + " of " + testList.size()+ " total (5 class prediction)"); 589 double precision5 = (double)succededInstances5/(double)wayListSizeWithoutUnclassified2;611 double precision5 = succededInstances5/(double)wayListSizeWithoutUnclassified2; 590 612 score5 = precision5; 591 613 System.out.println(precision5); 592 614 593 615 System.out.println("Succeeded " + succededInstances10 + " of " + testList.size()+ " total (10 class prediction)"); 594 double precision10 = (double)succededInstances10/(double)wayListSizeWithoutUnclassified2;616 double precision10 = succededInstances10/(double)wayListSizeWithoutUnclassified2; 595 617 score10 = precision10; 596 618 System.out.println(precision10); … … 602 624 int u = 0; 603 625 System.out.println("trainList size: " + wayListSizeWithoutUnclassified); 604 605 626 //set classes for each osm instance 606 627 int sizeToBeAddedToArray = 0; //this will be used to proper init the features array, adding the multiple vectors size 607 int lalala = 0;608 628 609 629 //System.out.println("starting classify instances"); … … 614 634 615 635 if(way.getClassIDs().isEmpty()){ 616 wayListSizeWithoutUnclassified = wayListSizeWithoutUnclassified-1;636 wayListSizeWithoutUnclassified -= 1; 617 637 u++; 618 638 } … … 672 692 } 673 693 for(int classID : way.getClassIDs()){ 674 lalala++;675 694 trainingSetWithUnknown2[k] = featureNodeArray; 676 695 GROUPS_ARRAY2[k] = classID; … … 744 763 745 764 if(way.getClassIDs().isEmpty()){ 746 wayListSizeWithoutUnclassified = wayListSizeWithoutUnclassified-1;765 wayListSizeWithoutUnclassified -= 1; 747 766 u++; 748 767 } … … 888 907 } 889 908 } 909 910 @Override 911 protected void done() { 912 try { 913 System.out.println("Training process complete! - > " + get()); 914 firePropertyChange("progress", getProgress(), 100); 915 setProgress(100); 916 } 917 catch (InterruptedException | ExecutionException ignore) { 918 System.out.println("Exception: " + ignore); 919 } 920 } 921 922 @Override 923 public void actionPerformed(ActionEvent ae) { 924 //cancel button, end process after clearing Dataset 925 } 890 926 } -
applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/UserDataExtractAndTrainWorker.java
r31106 r31441 1 1 package org.openstreetmap.josm.plugins.osmrec.personalization; 2 2 3 import java.awt.event.ActionEvent; 4 import java.awt.event.ActionListener; 5 import java.beans.PropertyChangeEvent; 6 import java.beans.PropertyChangeListener; 3 7 import java.text.SimpleDateFormat; 4 8 import java.util.ArrayList; … … 7 11 import java.util.List; 8 12 import java.util.TimeZone; 9 import java.util.logging.Level;10 import java.util.logging.Logger;11 13 import javax.swing.SwingWorker; 12 import org.opengis.referencing.FactoryException;13 14 import org.openstreetmap.josm.plugins.container.OSMWay; 14 import org.openstreetmap.josm.plugins.core.TrainWorker;15 15 import org.openstreetmap.josm.plugins.extractor.LanguageDetector; 16 16 import org.openstreetmap.josm.plugins.parsers.OSMParser; … … 22 22 */ 23 23 24 public class UserDataExtractAndTrainWorker extends SwingWorker<Void, Void> {24 public class UserDataExtractAndTrainWorker extends SwingWorker<Void, Void> implements ActionListener{ 25 25 26 26 private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; … … 28 28 private final String username; 29 29 private final Integer days; 30 private List<OSMWay> wayList ;30 private List<OSMWay> wayList = new ArrayList<>(); 31 31 private final boolean byArea; 32 32 private final String inputFilePath; … … 37 37 private final boolean topKIsSelected; 38 38 private final LanguageDetector languageDetector; 39 private int userTrainProgress = 0; 39 40 40 41 public UserDataExtractAndTrainWorker(String inputFilePath, String username, Integer days, boolean byArea, boolean validateFlag, … … 56 57 @Override 57 58 protected Void doInBackground() throws Exception { 59 60 System.out.println("UserDataExtractAndTrainWorker doInBackground initiating.."); 58 61 if(byArea){ 59 62 extractByArea(); … … 66 69 cParameterFromUser, topK, frequency, topKIsSelected, languageDetector, wayList); 67 70 68 trainByUser.executeTraining(); 71 System.out.println("trainByUser executing.."); 72 trainByUser.addPropertyChangeListener(new PropertyChangeListener() { 73 74 @Override 75 public void propertyChange(PropertyChangeEvent evt) { 76 if("progress".equals(evt.getPropertyName())) { 77 int progress = (Integer) evt.getNewValue(); 78 System.out.println("progress++ from property change listener, progress: " + progress); 79 setProgress(progress); 80 81 } 82 } 83 }); 84 85 86 87 88 89 trainByUser.doInBackground(); 90 setProgress(100); 69 91 return null; 70 92 } 71 93 72 94 private void extractHistory() { 73 wayList.clear(); 95 if(wayList != null){ 96 wayList.clear(); 97 } 98 74 99 produceTimeIntervals(days); 75 100 HistoryParser historyParser = new HistoryParser(username); … … 83 108 84 109 private void extractByArea() { 85 wayList.clear(); 86 OSMParser osmParser = null; 87 try { 88 osmParser = new OSMParser(inputFilePath); 89 90 } catch (FactoryException ex) { 91 Logger.getLogger(TrainWorker.class.getName()).log(Level.SEVERE, null, ex); 92 } 110 System.out.println("Extracting by Area.."); 111 112 if(wayList != null){ 113 wayList.clear(); 114 } 115 //System.out.println("wayList cleared."); 116 117 OSMParser osmParser = new OSMParser(inputFilePath); 118 osmParser.parseDocument(); 119 120 //System.out.println("OSMParser done."); 93 121 94 122 List<OSMWay> completeWayList = osmParser.getWayList(); 123 System.out.println("completeWayList size: " + completeWayList.size()); 124 System.out.println("populating wayList with edits from username: " + username); 95 125 for(OSMWay way : completeWayList){ 126 //System.out.println("current way user: " + way.getUser()); 96 127 if(way.getUser().equals(username)){ 128 System.out.println("found user edit!"); 97 129 wayList.add(way); 98 130 } 99 131 } 132 System.out.println("weeding wayList by user done."); 133 if(wayList.isEmpty()){ 134 System.out.println("User has not edited this Area. Try \"By time\" option."); 135 } 136 else{ 137 System.out.println("User has edited " + wayList.size() + " OSM entities in this area."); 138 } 100 139 } 101 140 … … 142 181 } while(cal.getTime().before(currentDate)); 143 182 } 183 184 @Override 185 public void actionPerformed(ActionEvent ae) { 186 //this.firePropertyChange("progress", userTrainProgress, userTrainProgress+10); 187 // if(userTrainProgress <100){ 188 // setProgress(userTrainProgress+10); 189 // } 190 191 } 144 192 } -
applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/parsers/OSMParser.java
r31106 r31441 48 48 private static final CoordinateReferenceSystem targetCRS = DefaultGeocentricCRS.CARTESIAN; 49 49 private final GeometryFactory geometryFactory = new GeometryFactory(); 50 private final MathTransform transform;50 private static MathTransform transform = null; 51 51 private final List<OSMNode> nodeList; //will be populated with nodes 52 52 private final List<OSMRelation> relationList; … … 61 61 private boolean inRelation = false; //becomes true when the parser is in a relarion node 62 62 63 public OSMParser(String osmXmlFileName) throws FactoryException { 63 public OSMParser(String osmXmlFileName) { 64 //System.out.println("creating osmParser.."); 64 65 this.osmXmlFileName = osmXmlFileName; 65 66 nodeList = new ArrayList<>(); … … 67 68 relationList = new ArrayList<>(); 68 69 nodesWithIDs = new HashMap<>(); 69 transform = CRS.findMathTransform(sourceCRS, targetCRS, true); 70 try { 71 transform = CRS.findMathTransform(sourceCRS, targetCRS, true); 72 } catch (FactoryException ex) { 73 Logger.getLogger(OSMParser.class.getName()).log(Level.SEVERE, null, ex); 74 } 75 //System.out.println("osmParser created!"); 70 76 } 71 77 … … 117 123 wayTmp = new OSMWay(); 118 124 wayTmp.setID(attributes.getValue("id")); 119 wayTmp.setUser(attributes.getValue("user")); 125 126 if(attributes.getValue("user") != null){ 127 wayTmp.setUser(attributes.getValue("user")); 128 } 129 else{ 130 wayTmp.setUser("undefined"); 131 } 132 //System.out.println("way user: " + attributes.getValue("user")); 133 120 134 inWay = true; 121 135 inNode = false; -
applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/parsers/Ontology.java
r31402 r31441 50 50 ontologyModel = ModelFactory.createOntologyModel(); 51 51 52 //org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.ERROR);52 org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.ERROR); 53 53 ontologyModel.read(owlFile, null); //Hide RDFDefaultErrorHandler from terminal to keep clear output. 54 //org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.INFO);54 org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.INFO); 55 55 56 56 listHierarchy = ontologyModel.listHierarchyRootClasses().toList(); … … 65 65 if (obj.hasSubClass()) { 66 66 67 for (Iterator i = obj.listSubClasses(true); i.hasNext();) {68 OntClass currentClass = (OntClass)i.next();67 for (Iterator<OntClass> i = obj.listSubClasses(true); i.hasNext();) { 68 OntClass currentClass = i.next(); 69 69 70 70 List<OntClass> superClasses = currentClass.listSuperClasses().toList();
Note:
See TracChangeset
for help on using the changeset viewer.