Changeset 24054 in osm
- Timestamp:
- 2010-11-04T10:44:32+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/pdfimport/src/pdfimport
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pdfimport/src/pdfimport/DuplicateNodesFinder.java
r24047 r24054 41 41 }); 42 42 43 //sweep from top to bottom. 43 44 double prevY = Double.NEGATIVE_INFINITY; 44 45 45 46 for(Point2D point: points) { 47 boolean mappedToOtherPoint = false; 48 46 49 if (point.getY() - prevY > tolerance){ 47 50 sweepLine.clear(); … … 49 52 } else { 50 53 //small offset, test against existing points (there may be more than one) 51 while (sweepLine.containsKey(point)){ 54 55 while (!mappedToOtherPoint && sweepLine.containsKey(point)) { 52 56 //a close point found 53 57 Point2D closePoint = sweepLine.get(point); 54 58 double dy = point.getY() - closePoint.getY(); 55 if (dy <= tolerance) {59 if (dy <= tolerance) { 56 60 //mark them as close 57 result.put(closePoint, point); 61 result.put(point, closePoint); 62 mappedToOtherPoint = true; 58 63 } 64 else 65 { 66 sweepLine.remove(point); 59 67 60 sweepLine.remove(closePoint);68 } 61 69 } 62 70 } 63 71 64 prevY = point.getY(); 65 sweepLine.put(point, point); 66 } 67 68 //remove cascading relations 69 for(Point2D pt: points) { 70 if (!result.containsKey(pt)){ 71 continue; 72 if (!mappedToOtherPoint) { 73 sweepLine.put(point, point); 72 74 } 73 75 74 Point2D rep = result.get(pt); 75 while (result.containsKey(rep)){ 76 rep = result.get(rep); 77 } 78 79 result.put(pt, rep); 76 prevY = point.getY(); 80 77 } 81 78 -
applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
r24019 r24054 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.BorderLayout;6 5 import java.awt.Cursor; 7 6 import java.awt.GridBagConstraints; … … 69 68 private JButton saveButton; 70 69 private JCheckBox debugModeCheck; 70 private JCheckBox mergeCloseNodesCheck; 71 private JTextField mergeCloseNodesTolerance; 71 72 72 73 public LoadPdfDialog() { … … 162 163 163 164 this.debugModeCheck = new JCheckBox(tr("Debug info")); 165 this.mergeCloseNodesCheck = new JCheckBox(tr("Merge close nodes")); 166 this.mergeCloseNodesTolerance = new JTextField(); 167 168 JPanel configPanel = new JPanel(new GridBagLayout()); 169 c.gridx = 0; c.gridy = 0; c.gridwidth = 1; 170 configPanel.add(this.mergeCloseNodesCheck, c); 171 c.gridx = 1; c.gridy = 0; c.gridwidth = 1; 172 configPanel.add(this.mergeCloseNodesTolerance, c); 173 174 c.gridx = 0; c.gridy = 1; c.gridwidth = 2; 175 configPanel.add(this.debugModeCheck, c); 164 176 165 177 … … 169 181 selectFilePanel.add(this.loadFileButton, c); 170 182 171 c.gridx = 0; c.gridy = 1; c.gridwidth = 1;172 selectFilePanel.add(this.debugModeCheck, c);173 183 174 184 JPanel projectionPanel = new JPanel(new GridBagLayout()); … … 221 231 okCancelPanel.add(this.saveButton); 222 232 223 JPanel panel = new JPanel(new BorderLayout()); 224 panel.add(okCancelPanel, BorderLayout.SOUTH); 225 panel.add(projectionPanel, BorderLayout.CENTER); 226 panel.add(selectFilePanel, BorderLayout.NORTH); 233 JPanel panel = new JPanel(new GridBagLayout()); 234 c.gridx = 0; c.gridy = 0; c.gridwidth = 1; 235 panel.add(configPanel, c); 236 c.gridx = 0; c.gridy = 1; c.gridwidth = 1; 237 panel.add(selectFilePanel, c); 238 c.gridx = 0; c.gridy = 2; c.gridwidth = 1; 239 panel.add(projectionPanel, c); 240 c.gridx = 0; c.gridy = 3; c.gridwidth = 1; 241 panel.add(okCancelPanel, c); 227 242 228 243 this.setSize(400, 400); … … 438 453 } 439 454 440 /* 441 File file = new File(fileName); 442 443 Document document = file.getDocument(); 444 Page page = document.getPages().get(0); 445 data.bounds = page.getBox(); 446 447 PDFStreamProcessor processor = new PDFStreamProcessor(data, document); 448 Contents c = page.getContents(); 449 processor.process(new ContentScanner(c)); 450 processor.finish(); 451 document.delete();*/ 455 if (this.mergeCloseNodesCheck.isSelected()) { 456 try { 457 double tolerance = Double.parseDouble(this.mergeCloseNodesTolerance.getText()); 458 data.mergeNodes(tolerance); 459 } 460 catch (Exception e) { 461 JOptionPane 462 .showMessageDialog( 463 Main.parent, 464 tr("Tolerance is not a number")); 465 return null; 466 } 467 } 452 468 453 469 data.optimize(); -
applications/editors/josm/plugins/pdfimport/src/pdfimport/PathOptimizer.java
r24046 r24054 71 71 } 72 72 73 public void optimize() 74 { 75 //fix points 73 74 public void mergeNodes(double tolerance) { 76 75 Map<Point2D, Point2D> pointMap = DuplicateNodesFinder.findDuplicateNodes(uniquePoints, POINT_TOLERANCE); 77 78 76 79 77 for(LayerContents layer: this.layers) { … … 81 79 this.concatenatePaths(layer); 82 80 } 83 84 81 } 82 83 public void optimize() 84 { 85 85 List<LayerContents> newLayers = new ArrayList<LayerContents>(); 86 86 /* … … 467 467 } 468 468 469 469 470 }
Note:
See TracChangeset
for help on using the changeset viewer.