Examples of BoundingXYVisitor


Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

            super(newLayer, reader, progressMonitor);
        }

        @Override
        protected void computeBboxAndCenterScale(Bounds bounds) {
            BoundingXYVisitor v = new BoundingXYVisitor();
            if (bounds != null) {
                v.visit(bounds);
            } else {
                v.computeBoundingBox(dataSet.getNodes());
            }
            // Main.map.mapView.recalculateCenterScale(v);
        }
View Full Code Here

Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

    // workaround for #1461 (zoom to download bounding box instead of all
    // data)
    // In case we already have an existing data layer ...
    Collection<DataSource> dataSources = Main.main.editLayer().data.dataSources;
    // ... with bounding box[es] of data loaded from OSM or a file...
    BoundingXYVisitor bbox = new BoundingXYVisitor();
    for (DataSource ds : dataSources) {
      if (ds.bounds != null) {
        bbox.visit(Main.proj.latlon2eastNorth(ds.bounds.max));
        bbox.visit(Main.proj.latlon2eastNorth(ds.bounds.min));
      }
      if (bbox.max != null && bbox.min != null
          && !bbox.max.equals(bbox.min)) {
        // ... we zoom to it's bounding box
        recalculateCenterScale(bbox);
View Full Code Here

Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

        }
        zoomTo(sel);
    }

    public static void zoomTo(Collection<OsmPrimitive> sel) {
        BoundingXYVisitor bboxCalculator = new BoundingXYVisitor();
        bboxCalculator.computeBoundingBox(sel);
        // increase bbox by 0.001 degrees on each side. this is required
        // especially if the bbox contains one single node, but helpful
        // in most other cases as well.
        bboxCalculator.enlargeBoundingBox();
        if (bboxCalculator.getBounds() != null) {
            Main.map.mapView.recalculateCenterScale(bboxCalculator);
        }
    }
View Full Code Here

Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

                break;
            case "next":
                Main.map.mapView.zoomNext();
                break;
            default:
                BoundingXYVisitor bbox = getBoundingBox();
                if (bbox != null && bbox.getBounds() != null) {
                    Main.map.mapView.recalculateCenterScale(bbox);
                }
            }
        }
        putValue("active", true);
View Full Code Here

Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

        if (layers.isEmpty()) return null;
        return layers.get(0);
    }

    private BoundingXYVisitor getBoundingBox() {
        BoundingXYVisitor v = "problem".equals(mode) ? new ValidatorBoundingXYVisitor() : new BoundingXYVisitor();

        switch(mode) {
        case "problem":
            TestError error = Main.map.validatorDialog.getSelectedError();
            if (error == null) return null;
            ((ValidatorBoundingXYVisitor) v).visit(error);
            if (v.getBounds() == null) return null;
            v.enlargeBoundingBox(Main.pref.getDouble("validator.zoom-enlarge-bbox", 0.0002));
            break;
        case "data":
            for (Layer l : Main.map.mapView.getAllLayers()) {
                l.visitBoundingBox(v);
            }
            break;
        case "layer":
            if (Main.main.getActiveLayer() == null)
                return null;
            // try to zoom to the first selected layer
            Layer l = getFirstSelectedLayer();
            if (l == null) return null;
            l.visitBoundingBox(v);
            break;
        case "selection":
        case "conflict":
            Collection<OsmPrimitive> sel = new HashSet<>();
            if ("selection".equals(mode)) {
                sel = getCurrentDataSet().getSelected();
            } else {
                Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict();
                if (c != null) {
                    sel.add(c.getMy());
                } else if (Main.map.conflictDialog.getConflicts() != null) {
                    sel = Main.map.conflictDialog.getConflicts().getMyConflictParties();
                }
            }
            if (sel.isEmpty()) {
                JOptionPane.showMessageDialog(
                        Main.parent,
                        ("selection".equals(mode) ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to")),
                        tr("Information"),
                        JOptionPane.INFORMATION_MESSAGE
                );
                return null;
            }
            for (OsmPrimitive osm : sel) {
                osm.accept(v);
            }

            // Increase the bounding box by up to 100% to give more context.
            v.enlargeBoundingBoxLogarithmically(100);
            // Make the bounding box at least 100 meter wide to
            // ensure reasonable zoom level when zooming onto single nodes.
            v.enlargeToMinSize(Main.pref.getDouble("zoom_to_selection_min_size_in_meter", 100));
            break;
        case "download":
            Bounds bounds = DownloadDialog.getSavedDownloadBounds();
            if (bounds != null) {
                try {
                    v.visit(bounds);
                } catch (Exception e) {
                    Main.warn(e);
                }
            }
            break;
View Full Code Here

Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

        } else if (Main.isDisplayingMapView()) {
            // make sure this isn't called unless there *is* a MapView
            GuiHelper.executeByMainWorkerInEDT(new Runnable() {
                @Override
                public void run() {
                    BoundingXYVisitor bbox1 = new BoundingXYVisitor();
                    bbox1.visit(bbox);
                    Main.map.mapView.recalculateCenterScale(bbox1);
                }
            });
        }
    }
View Full Code Here

Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

            updateEnabledState();
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            BoundingXYVisitor box = new BoundingXYVisitor();
            Collection<OsmPrimitive> sel = model.getSelected();
            if (sel.isEmpty()) return;
            box.computeBoundingBox(sel);
            if (box.getBounds() == null)
                return;
            box.enlargeBoundingBox();
            Main.map.mapView.recalculateCenterScale(box);
        }
View Full Code Here

Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

                targetLayer.onPostDownloadFromServer();
            }
        }

        protected void computeBboxAndCenterScale() {
            BoundingXYVisitor v = new BoundingXYVisitor();
            if (currentBounds != null) {
                v.visit(currentBounds);
            } else {
                v.computeBoundingBox(dataSet.getNodes());
            }
            Main.map.mapView.recalculateCenterScale(v);
        }
View Full Code Here

Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

    /**
     * Set the new dimension to the view.
     */
    public void recalculateCenterScale(BoundingXYVisitor box) {
        if (box == null) {
            box = new BoundingXYVisitor();
        }
        if (box.getBounds() == null) {
            box.visit(getProjection().getWorldBoundsLatLon());
        }
        if (!box.hasExtend()) {
View Full Code Here

Examples of org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor

        OsmDataLayer layer= getEditLayer();
        if (layer == null)
            return false;
        Collection<DataSource> dataSources = ds.dataSources;
        // ... with bounding box[es] of data loaded from OSM or a file...
        BoundingXYVisitor bbox = new BoundingXYVisitor();
        for (DataSource source : dataSources) {
            bbox.visit(source.bounds);
        }
        if (bbox.hasExtend()) {
            // ... we zoom to it's bounding box
            recalculateCenterScale(bbox);
            return true;
        }
        return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.