Changeset 24654 in osm


Ignore:
Timestamp:
2010-12-08T15:53:35+01:00 (14 years ago)
Author:
extropy
Message:

Pfgimport: added option to filter orthogonal shapes (buildings)

Location:
applications/editors/josm/plugins/pdfimport/src/pdfimport
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java

    r24214 r24654  
    137137        private JCheckBox splitOnShapeClosedCheck;
    138138        private JCheckBox splitOnSingleSegmentCheck;
     139        private JCheckBox splitOnOrthogonalCheck;
    139140
    140141
     
    254255                this.splitOnShapeClosedCheck = new JCheckBox(tr("Shape closed"));
    255256                this.splitOnSingleSegmentCheck = new JCheckBox(tr("Single segments"));
     257                this.splitOnOrthogonalCheck = new JCheckBox(tr("Orthogonal shapes"));
    256258
    257259                JPanel configPanel = new JPanel(new GridBagLayout());
     
    308310                c.gridx = 1; c.gridy = 8; c.gridwidth = 1;
    309311                configPanel.add(this.splitOnColorChangeCheck, c);
     312                c.gridx = 2; c.gridy = 8; c.gridwidth = 1;
     313                configPanel.add(this.splitOnOrthogonalCheck, c);
    310314
    311315
     
    767771                monitor.setTicks(95);
    768772                monitor.setCustomText(tr("Finalizing layers"));
    769                 data.splitLayersByPathKind(this.splitOnShapeClosedCheck.isSelected(), this.splitOnSingleSegmentCheck.isSelected());
     773                data.splitLayersByPathKind(this.splitOnShapeClosedCheck.isSelected(), this.splitOnSingleSegmentCheck.isSelected(), this.splitOnOrthogonalCheck.isSelected());
    770774                data.finish();
    771775
  • applications/editors/josm/plugins/pdfimport/src/pdfimport/PathOptimizer.java

    r24214 r24654  
    164164        }
    165165
    166         public void splitLayersByPathKind(boolean closed, boolean single) {
     166        public void splitLayersByPathKind(boolean closed, boolean single, boolean orthogonal) {
    167167                List<LayerContents> newLayers = new ArrayList<LayerContents>();
    168168                for(LayerContents l: this.layers) {
    169                         List<LayerContents> splitResult = splitBySegmentKind(l, closed, single);
     169                        List<LayerContents> splitResult = splitBySegmentKind(l, closed, single, orthogonal);
    170170
    171171                        for(LayerContents ll: splitResult) {
     
    583583        }
    584584
    585         private List<LayerContents> splitBySegmentKind(LayerContents layer, boolean closed, boolean single)
     585        private List<LayerContents> splitBySegmentKind(LayerContents layer, boolean closed, boolean single, boolean orthogonal)
    586586        {
    587587                if (!closed && !single) {
    588                         return Collections.singletonList(layer);
    589                 }
     588                        return Collections.singletonList(layer);                       
     589                }
     590               
     591                OrthogonalShapesFilter of = new OrthogonalShapesFilter(10);
    590592
    591593                List<PdfPath> singleSegmentPaths = new ArrayList<PdfPath>();
    592594                List<PdfPath> multiSegmentPaths = new ArrayList<PdfPath>();
    593595                List<PdfPath> closedPaths = new ArrayList<PdfPath>();
     596                List<PdfPath> orthogonalPaths = new ArrayList<PdfPath>();
     597                List<PdfPath> orthogonalClosedPaths = new ArrayList<PdfPath>();
    594598
    595599                for(PdfPath path: layer.paths) {
    596                         if (path.points.size() <= 3 && single) {
     600                        boolean pathOrthgonal = orthogonal && of.isOrthogonal(path);
     601                        boolean pathUnclosed = !path.isClosed() && closed;
     602                        boolean pathSingleSegment = path.points.size() <= 3 && single;
     603                       
     604                        if (pathSingleSegment) {
    597605                                singleSegmentPaths.add(path);
    598606                        }
    599                         else if (!path.isClosed() && closed) {
    600                                 multiSegmentPaths.add(path);
     607                        else if (pathUnclosed) {
     608                               
     609                                if (pathOrthgonal) {
     610                                        orthogonalPaths.add(path);
     611                                }
     612                                else {
     613                                        multiSegmentPaths.add(path);
     614                                }
    601615                        }
    602616                        else {
    603                                 closedPaths.add(path);
     617                                if (pathOrthgonal) {
     618                                        orthogonalClosedPaths.add(path);       
     619                                }
     620                                else
     621                                {
     622                                        closedPaths.add(path);
     623                                }
     624                               
    604625                        }
    605626                }
     
    618639                        LayerContents l = new LayerContents();
    619640                        l.paths = singleSegmentPaths;
     641                        l.info = layer.info.copy();
     642                        layers.add(l);
     643                }
     644               
     645
     646                if (orthogonalPaths.size() > 0) {
     647                        LayerContents l = new LayerContents();
     648                        l.paths = orthogonalPaths;
     649                        l.info = layer.info.copy();
     650                        layers.add(l);
     651                }
     652               
     653                if (orthogonalClosedPaths.size() > 0) {
     654                        LayerContents l = new LayerContents();
     655                        l.paths = orthogonalClosedPaths;
    620656                        l.info = layer.info.copy();
    621657                        layers.add(l);
Note: See TracChangeset for help on using the changeset viewer.