Package org.openstreetmap.josm.data.osm

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


        }
    }

    @Override
    protected void realRun() throws SAXException, IOException, OsmTransferException {
        this.ds = new DataSet();
        DataSet theirDataSet;
        try {
            synchronized(this) {
                if (canceled) return;
                multiObjectReader = new MultiFetchServerObjectReader();
            }
View Full Code Here


                List<Way> allWays = new ArrayList<>();
                for (Multipolygon pol : result.polygons) {
                    allWays.add(pol.outerWay);
                    allWays.addAll(pol.innerWays);
                }
                DataSet ds = Main.main.getCurrentDataSet();
                ds.setSelected(allWays);
                Main.map.mapView.repaint();
            } else {
                new Notification(
                        tr("No intersection found. Nothing was changed."))
                        .setIcon(JOptionPane.INFORMATION_MESSAGE)
View Full Code Here

            ChangesetListModel model = getCurrentChangesetListModel();
            Set<Integer> sel = model.getSelectedChangesetIds();
            if (sel.isEmpty())
                return;

            DataSet ds = Main.main.getEditLayer().data;
            selectObjectsByChangesetIds(ds,sel);
        }
View Full Code Here

     */
    public void setErrors(List<TestError> newerrors) {
        if (errors == null)
            return;
        clearErrors();
        DataSet ds = Main.main.getCurrentDataSet();
        for (TestError error : newerrors) {
            if (!error.getIgnored()) {
                errors.add(error);
                if (ds != null) {
                    ds.addDataSetListener(error);
                }
            }
        }
        if (isVisible()) {
            buildTree();
View Full Code Here

        return updateCount;
    }

    private void clearErrors() {
        if (errors != null) {
            DataSet ds = Main.main.getCurrentDataSet();
            if (ds != null) {
                for (TestError e : errors) {
                    ds.removeDataSetListener(e);
                }
            }
            errors.clear();
        }
    }
View Full Code Here

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                List<PrimitiveData> primitives = Main.pasteBuffer.getDirectlyAdded();
                DataSet ds = getLayer().data;
                List<OsmPrimitive> toAdd = new ArrayList<>();
                boolean hasNewInOtherLayer = false;

                for (PrimitiveData primitive: primitives) {
                    OsmPrimitive primitiveInDs = ds.getPrimitiveById(primitive);
                    if (primitiveInDs != null) {
                        toAdd.add(primitiveInDs);
                    } else if (!primitive.isNew()) {
                        OsmPrimitive p = primitive.getType().newInstance(primitive.getUniqueId(), true);
                        ds.addPrimitive(p);
                        toAdd.add(p);
                    } else {
                        hasNewInOtherLayer = true;
                        break;
                    }
View Full Code Here

                } else {
                    Area toDownload = null;
                    if (!newLayer) {
                        // find out whether some data has already been downloaded
                        Area present = null;
                        DataSet ds = Main.main.getCurrentDataSet();
                        if (ds != null) {
                            present = ds.getDataSourceArea();
                        }
                        if (present != null && !present.isEmpty()) {
                            toDownload = new Area(new Rectangle2D.Double(minlon,minlat,maxlon-minlon,maxlat-minlat));
                            toDownload.subtract(present);
                            if (!toDownload.isEmpty()) {
                                // the result might not be a rectangle (L shaped etc)
                                Rectangle2D downloadBounds = toDownload.getBounds2D();
                                minlat = downloadBounds.getMinY();
                                minlon = downloadBounds.getMinX();
                                maxlat = downloadBounds.getMaxY();
                                maxlon = downloadBounds.getMaxX();
                            }
                        }
                    }
                    if (toDownload != null && toDownload.isEmpty()) {
                        Main.info("RemoteControl: no download necessary");
                    } else {
                        Future<?> future = osmTask.download(newLayer, new Bounds(minlat,minlon,maxlat,maxlon), null /* let the task manage the progress monitor */);
                        Main.worker.submit(new PostDownloadHandler(osmTask, future));
                    }
                }
            }
        } catch (Exception ex) {
            Main.warn("RemoteControl: Error parsing load_and_zoom remote control request:");
            Main.error(ex);
            throw new RequestHandlerErrorException(ex);
        }

        /**
         * deselect objects if parameter addtags given
         */
        if (args.containsKey("addtags")) {
            GuiHelper.executeByMainWorkerInEDT(new Runnable() {
                @Override
                public void run() {
                    DataSet ds = Main.main.getCurrentDataSet();
                    if(ds == null) // e.g. download failed
                        return;
                    ds.clearSelection();
                }
            });
        }

        final Bounds bbox = new Bounds(minlat, minlon, maxlat, maxlon);
        if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) {
            // select objects after downloading, zoom to selection.
            GuiHelper.executeByMainWorkerInEDT(new Runnable() {
                @Override
                public void run() {
                    Set<OsmPrimitive> newSel = new HashSet<>();
                    DataSet ds = Main.main.getCurrentDataSet();
                    if (ds == null) // e.g. download failed
                        return;
                    for (SimplePrimitiveId id : toSelect) {
                        final OsmPrimitive p = ds.getPrimitiveById(id);
                        if (p != null) {
                            newSel.add(p);
                        }
                    }
                    toSelect.clear();
                    ds.setSelected(newSel);
                    zoom(newSel, bbox);
                    if (Main.isDisplayingMapView() && Main.map.relationListDialog != null) {
                        Main.map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342
                        Main.map.relationListDialog.dataChanged(null);
                        Main.map.relationListDialog.selectRelations(Utils.filteredCollection(newSel, Relation.class));
                    }
                }
            });
        } else if (args.containsKey("search") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) {
            try {
                final DataSet ds = Main.main.getCurrentDataSet();
                final SearchCompiler.Match search = SearchCompiler.compile(args.get("search"), false, false);
                final Collection<OsmPrimitive> filteredPrimitives = Utils.filter(ds.allPrimitives(), search);
                ds.setSelected(filteredPrimitives);
                zoom(filteredPrimitives, bbox);
            } catch (SearchCompiler.ParseError ex) {
                Main.error(ex);
                throw new RequestHandlerErrorException(ex);
            }
View Full Code Here

                return p;
            } //  do not go backward!

            projectionSource=null;
            if (snapToProjections) {
                DataSet ds = getCurrentDataSet();
                Collection<Way> selectedWays = ds.getSelectedWays();
                if (selectedWays.size()==1) {
                    Way w = selectedWays.iterator().next();
                    Collection <EastNorth> pointsToProject = new ArrayList<>();
                    if (w.getNodesCount()<1000) {
                        for (Node n: w.getNodes()) {
View Full Code Here

            putValue(SMALL_ICON, ImageProvider.get("dialogs/relation", "deletemembers"));
            updateEnabledState();
        }

        protected void updateEnabledState() {
            DataSet ds = getLayer().data;
            if (ds == null || ds.getSelected().isEmpty()) {
                setEnabled(false);
                return;
            }
            // only enable the action if we have members referring to the
            // selected primitives
            //
            setEnabled(memberTableModel.hasMembersReferringTo(ds.getSelected()));
        }
View Full Code Here

            }
            objectReader.append(children);
            progressMonitor.indeterminateSubTask(
                    buildDownloadFeedbackMessage()
            );
            final DataSet dataSet = objectReader.parseOsm(progressMonitor
                    .createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
            if (dataSet == null)
                return;
            dataSet.deleteInvisible();
            synchronized (this) {
                if (canceled) return;
                objectReader = null;
            }
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.