Package org.openstreetmap.josm.data.osm

Examples of org.openstreetmap.josm.data.osm.DataSet


                    TestError error = (TestError) nodeInfo;
                    sel.addAll(error.getSelectablePrimitives());
                }
            }
        }
        DataSet ds = Main.main.getCurrentDataSet();
        if (ds != null) {
            ds.setSelected(sel);
        }
    }
View Full Code Here


    /**
     * removes any highlighting that may have been set beforehand.
     */
    private void removeHighlighting() {
        highlightHelper.clear();
        DataSet ds = getCurrentDataSet();
        if(ds != null) {
            ds.clearHighlightedWaySegments();
        }
    }
View Full Code Here

        }
    }

    private void repaintIfRequired(Set<OsmPrimitive> newHighlights, WaySegment newHighlightedWaySegment) {
        boolean needsRepaint = false;
        DataSet ds = getCurrentDataSet();

        if(newHighlightedWaySegment == null && oldHighlightedWaySegment != null) {
            if(ds != null) {
                ds.clearHighlightedWaySegments();
                needsRepaint = true;
            }
            oldHighlightedWaySegment = null;
        } else if(newHighlightedWaySegment != null && !newHighlightedWaySegment.equals(oldHighlightedWaySegment)) {
            if(ds != null) {
                ds.setHighlightedWaySegments(Collections.singleton(newHighlightedWaySegment));
                needsRepaint = true;
            }
            oldHighlightedWaySegment = newHighlightedWaySegment;
        }
        needsRepaint |= highlightHelper.highlightOnly(newHighlights);
View Full Code Here

        Main.map.repaint();
    }

    protected void downloadParents(long id, OsmPrimitiveType type, ProgressMonitor progressMonitor) throws OsmTransferException{
        reader = new OsmServerBackreferenceReader(id, type);
        DataSet ds = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false));
        synchronized(this) { // avoid race condition in cancel()
            reader = null;
        }
        Collection<Way> ways = ds.getWays();

        DataSetMerger merger;
        if (!ways.isEmpty()) {
            Set<Node> nodes = new HashSet<>();
            for (Way w: ways) {
                // Ensure each node is only listed once
                nodes.addAll(w.getNodes());
            }
            // Don't retrieve any nodes we've already grabbed
            nodes.removeAll(targetLayer.data.getNodes());
            if (!nodes.isEmpty()) {
                reader = new MultiFetchServerObjectReader();
                ((MultiFetchServerObjectReader)reader).append(nodes);
                DataSet wayNodes = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false));
                synchronized(this) { // avoid race condition in cancel()
                    reader = null;
                }
                merger = new DataSetMerger(ds, wayNodes);
                merger.merge();
View Full Code Here

     * @return The Future representing the asynchronous download task
     */
    public Future<?> download(boolean newLayer, List<Rectangle2D> rects, boolean osmData, boolean gpxData, ProgressMonitor progressMonitor) {
        this.progressMonitor = progressMonitor;
        if (newLayer) {
            Layer l = new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null);
            Main.main.addLayer(l);
            Main.map.mapView.setActiveLayer(l);
        }

        int n = (osmData && gpxData ? 2 : 1)*rects.size();
 
View Full Code Here

     */
    public Set<OsmPrimitive> getDownloadedPrimitives() {
        HashSet<OsmPrimitive> ret = new HashSet<>();
        for (DownloadTask task : tasks) {
            if (task instanceof DownloadOsmTask) {
                DataSet ds = ((DownloadOsmTask) task).getDownloadedData();
                if (ds != null) {
                    ret.addAll(ds.allPrimitives());
                }
            }
        }
        return ret;
    }
View Full Code Here

            final OsmDataLayer editLayer = Main.main.getEditLayer();
            if (editLayer != null && osmData) {
                final Set<OsmPrimitive> myPrimitives = getCompletePrimitives(editLayer.data);
                for (DownloadTask task : tasks) {
                    if (task instanceof DownloadOsmTask) {
                        DataSet ds = ((DownloadOsmTask) task).getDownloadedData();
                        if (ds != null) {
                            // myPrimitives.removeAll(ds.allPrimitives()) will do the same job but much slower
                            for (OsmPrimitive primitive: ds.allPrimitives()) {
                                myPrimitives.remove(primitive);
                            }
                        }
                    }
                }
View Full Code Here

     */
    public static void handlePrimitiveGoneException(long id, OsmPrimitiveType type) {
        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
        reader.append(getCurrentDataSet(), id, type);
        try {
            DataSet ds = reader.parseOsm(NullProgressMonitor.INSTANCE);
            Main.main.getEditLayer().mergeFrom(ds);
        } catch(Exception e) {
            ExceptionDialogUtil.explainException(e);
        }
    }
View Full Code Here

        return ret == 0;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        DataSet ds = getCurrentDataSet();
        ds.beginUpdate();
        try {
            List<Way> ways = OsmPrimitive.getFilteredList(ds.getSelected(), Way.class);
            if (ways.isEmpty()) {
                alertSelectAtLeastOneWay();
                return;
            } else if (!confirmWayWithNodesOutsideBoundingBox(ways)) {
                return;
            } else if (ways.size() > 10 && !confirmSimplifyManyWays(ways.size())) {
                return;
            }

            Collection<Command> allCommands = new LinkedList<>();
            for (Way way: ways) {
                SequenceCommand simplifyCommand = simplifyWay(way);
                if (simplifyCommand == null) {
                    continue;
                }
                allCommands.add(simplifyCommand);
            }
            if (allCommands.isEmpty()) return;
            SequenceCommand rootCommand = new SequenceCommand(
                    trn("Simplify {0} way", "Simplify {0} ways", allCommands.size(), allCommands.size()),
                    allCommands
                    );
            Main.main.undoRedo.add(rootCommand);
        } finally {
            ds.endUpdate();
        }
        Main.map.repaint();
    }
View Full Code Here

        HashSet<OsmPrimitive> newHighlights = new HashSet<>();

        virtualManager.clear();
        if(mode == Mode.move) {
            if (!dragInProgress() && virtualManager.activateVirtualNodeNearPoint(e.getPoint())) {
                DataSet ds = getCurrentDataSet();
                if (ds != null && drawTargetHighlight) {
                    ds.setHighlightedVirtualNodes(virtualManager.virtualWays);
                }
                mv.setNewCursor(SelectActionCursor.virtual_node.cursor(), this);
                // don't highlight anything else if a virtual node will be
                return repaintIfRequired(newHighlights);
            }
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.osm.DataSet

Copyright © 2018 www.massapicom. 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.