Package org.openstreetmap.josm.data.osm

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


        getLayer().data.setSelected(primitivesToSelect);
        return true;
    }

    @Override public void undoCommand() {
        DataSet ds = getLayer().data;

        if (createdPrimitives == null) {
            createdPrimitives = new ArrayList<>(data.size());
            createdPrimitivesToSelect = new ArrayList<>(toSelect.size());

            for (PrimitiveData pd : data) {
                OsmPrimitive p = ds.getPrimitiveById(pd);
                createdPrimitives.add(p);
                if (toSelect.contains(pd)) {
                    createdPrimitivesToSelect.add(p);
                }
            }
            createdPrimitives = PurgeCommand.topoSort(createdPrimitives);

            for (PrimitiveData p : data) {
                ds.removePrimitive(p);
            }
            data = null;
            toSelect = null;

        } else {
            for (OsmPrimitive osm : createdPrimitives) {
                ds.removePrimitive(osm);
            }
        }
    }
View Full Code Here


     */
    public MultiFetchServerObjectReader() {
        nodes = new LinkedHashSet<>();
        ways = new LinkedHashSet<>();
        relations = new LinkedHashSet<>();
        this.outputDataSet = new DataSet();
        this.missingPrimitives = new LinkedHashSet<>();
    }
View Full Code Here

                true);
    }

    @Override
    public void actionPerformed(ActionEvent ev) {
        DataSet ds = Main.main.getCurrentDataSet();
        SelectNonBranchingWaySequences ws = new SelectNonBranchingWaySequences(ds.getSelectedWays());
        ws.extend(ds);
    }
View Full Code Here

         * @return the {@link DataSet} resulting of this operation
         * @throws OsmTransferException if an error occurs while communicating with the API server
         */
        protected DataSet singleGetId(OsmPrimitiveType type, long id, ProgressMonitor progressMonitor) throws OsmTransferException {
            String request = buildRequestString(type, id);
            DataSet result = null;
            try (InputStream in = getInputStream(request, NullProgressMonitor.INSTANCE)) {
                if (in == null) return null;
                progressMonitor.subTask(tr("Downloading OSM data..."));
                try {
                    result = OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(1, false));
View Full Code Here

         * @param pkg the set of ids
         * @return the {@link FetchResult} of this operation
         * @throws OsmTransferException if an error occurs while communicating with the API server
         */
        protected FetchResult singleGetIdPackage(OsmPrimitiveType type, Set<Long> pkg, ProgressMonitor progressMonitor) throws OsmTransferException {
            FetchResult result = new FetchResult(new DataSet(), new HashSet<PrimitiveId>());
            String baseUrl = OsmApi.getOsmApi().getBaseUrl();
            for (long id : pkg) {
                try {
                    String msg = "";
                    switch (type) {
View Full Code Here

     */
    public Collection<OsmPrimitive> getInProgressSelection() {
        if (map != null && map.mapMode instanceof DrawAction) {
            return ((DrawAction) map.mapMode).getInProgressSelection();
        } else {
            DataSet ds = getCurrentDataSet();
            if (ds == null) return null;
            return ds.getSelected();
        }
    }
View Full Code Here

            Collection<Way> waysToCheck = new ArrayList<>(ds.getWays());
            if (isReadFull() ||primitiveType.equals(OsmPrimitiveType.NODE)) {
                for (Way way: waysToCheck) {
                    if (!way.isNew() && way.hasIncompleteNodes()) {
                        OsmServerObjectReader reader = new OsmServerObjectReader(way.getId(), OsmPrimitiveType.from(way), true /* read full */);
                        DataSet wayDs = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false));
                        DataSetMerger visitor = new DataSetMerger(ds, wayDs);
                        visitor.merge();
                    }
                }
            }
            if (isReadFull()) {
                Collection<Relation> relationsToCheck  = new ArrayList<>(ds.getRelations());
                for (Relation relation: relationsToCheck) {
                    if (!relation.isNew() && relation.hasIncompleteMembers()) {
                        OsmServerObjectReader reader = new OsmServerObjectReader(relation.getId(), OsmPrimitiveType.from(relation), true /* read full */);
                        DataSet wayDs = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false));
                        DataSetMerger visitor = new DataSetMerger(ds, wayDs);
                        visitor.merge();
                    }
                }
            }
View Full Code Here

        if (progressMonitor == null) {
            progressMonitor = NullProgressMonitor.INSTANCE;
        }
        try {
            progressMonitor.beginTask(null, 3);
            DataSet ret = new DataSet();
            if (primitiveType.equals(OsmPrimitiveType.NODE)) {
                DataSet ds = getReferringWays(progressMonitor.createSubTaskMonitor(1, false));
                DataSetMerger visitor = new DataSetMerger(ret,ds);
                visitor.merge();
                ret = visitor.getTargetDataSet();
            }
            DataSet ds = getReferringRelations(progressMonitor.createSubTaskMonitor(1, false));
            DataSetMerger visitor = new DataSetMerger(ret,ds);
            visitor.merge();
            ret = visitor.getTargetDataSet();
            if (ret != null) {
                readIncompletePrimitives(ret, progressMonitor.createSubTaskMonitor(1, false));
View Full Code Here

        if (Main.commandLineArgs.length > 0) {
            text.append("Program arguments: "+ Arrays.toString(Main.commandLineArgs));
            text.append("\n");
        }
        if (Main.main != null) {
            DataSet dataset = Main.main.getCurrentDataSet();
            if (dataset != null) {
                String result = DatasetConsistencyTest.runTests(dataset);
                if (result.length() == 0) {
                    text.append("Dataset consistency test: No problems found\n");
                } else {
View Full Code Here

        TaggingPresets.addTaggingPresets(TaggingPresetReader.readAll(source, true));

        Comparator<Relation> comparator = DefaultNameFormatter.getInstance().getRelationComparator();

        try (InputStream is = new FileInputStream(TestUtils.getRegressionDataFile(9632, "data.osm.zip"))) {
            DataSet ds = OsmReader.parseDataSet(Compression.ZIP.getUncompressedInputStream(is), null);

            // Test with 3 known primitives causing the problem. Correct order is p1, p3, p2 with this preset
            Relation p1 = (Relation) ds.getPrimitiveById(2983382, OsmPrimitiveType.RELATION);
            Relation p2 = (Relation) ds.getPrimitiveById(550315, OsmPrimitiveType.RELATION);
            Relation p3 = (Relation) ds.getPrimitiveById(167042, OsmPrimitiveType.RELATION);

            System.out.println("p1: "+DefaultNameFormatter.getInstance().format(p1)+" - "+p1); // route_master ("Bus 453", 6 members)
            System.out.println("p2: "+DefaultNameFormatter.getInstance().format(p2)+" - "+p2); // TMC ("A 6 Kaiserslautern - Mannheim [negative]", 123 members)
            System.out.println("p3: "+DefaultNameFormatter.getInstance().format(p3)+" - "+p3); // route(lcn Sal  Salier-Radweg(412 members)

            assertTrue(comparator.compare(p1, p2) == -1); // p1 < p2
            assertTrue(comparator.compare(p2, p1) ==  1); // p2 > p1

            assertTrue(comparator.compare(p1, p3) == -1); // p1 < p3
            assertTrue(comparator.compare(p3, p1) ==  1); // p3 > p1
            assertTrue(comparator.compare(p2, p3) ==  1); // p2 > p3
            assertTrue(comparator.compare(p3, p2) == -1); // p3 < p2

            Relation[] relations = new ArrayList<>(ds.getRelations()).toArray(new Relation[0]);

            TestUtils.checkComparableContract(comparator, relations);
        }
    }
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.