Package org.locationtech.geogig.repository

Examples of org.locationtech.geogig.repository.WorkingTree


        ImmutableList<Optional<Object>> values = revFeature.get().getValues();
        assertEquals(4, values.size());

        // unmap without having made any changes and check that the canonical folders are not
        // modified
        WorkingTree workTree = geogig.getRepository().workingTree();
        geogig.command(OSMUnmapOp.class)/* .setMapping(mapping) */.setPath("residential").call();
        long unstaged = workTree.countUnstaged("way").count();
        assertEquals(0, unstaged);
        unstaged = workTree.countUnstaged("node").count();
        assertEquals(0, unstaged);

        // modify a mapped feature. We change the value of 'name_alias' tag to "newvalue"
        ArrayList<Coordinate> coords = Lists.newArrayList(((Geometry) values.get(2).get())
                .getCoordinates());
View Full Code Here


                    .getRules().size());
        }

        geogig.command(OSMImportOp.class).setDataSource(data.getAbsolutePath()).setMapping(mapping)
                .setNoRaw(true).call();
        WorkingTree workingTree = geogig.getContext().workingTree();
        List<NodeRef> featureTypeTrees = workingTree.getFeatureTypeTrees();
        assertEquals(2, featureTypeTrees.size());
        Set<String> expectedNames = newHashSet("osm_roads", "osm_roads_main");
        assertTrue(expectedNames.contains(featureTypeTrees.get(0).name()));
        assertTrue(expectedNames.contains(featureTypeTrees.get(1).name()));
    }
View Full Code Here

        objectInserter.insert(commit);
        Optional<Ref> newHead = geogig.command(UpdateRef.class).setName("refs/heads/master")
                .setNewValue(commitId).call();
        assertTrue(newHead.isPresent());

        WorkingTree workTree = repo.workingTree();
        workTree.delete(linesName, lines1.getIdentifier().getID());
        geogig.command(AddOp.class).call();

        newRootTreeId = geogig.command(WriteTree2.class).setOldRoot(tree(newRootTreeId)).call(); // newRootTreeId
                                                                                                 // =
                                                                                                 // index.writeTree(newRootTreeId,
View Full Code Here

    }

    @Test
    public void testWriteEmptyPathAddAll() throws Exception {
        insert(lines1);
        WorkingTree workingTree = geogig.getRepository().workingTree();
        workingTree.createTypeTree(pointsName, pointsType);

        List<NodeRef> workHead = toList(geogig.command(LsTreeOp.class).setReference(Ref.WORK_HEAD)
                .setStrategy(Strategy.DEPTHFIRST).call());

        assertEquals(3, workHead.size());
View Full Code Here

        assertEquals(1, filtered.size());
    }

    @Test
    public void testWriteEmptyPath() throws Exception {
        WorkingTree workingTree = geogig.getRepository().workingTree();
        workingTree.createTypeTree(pointsName, pointsType);
        workingTree.createTypeTree(linesName, linesType);

        List<NodeRef> workHead = toList(geogig.command(LsTreeOp.class).setReference(Ref.WORK_HEAD)
                .setStrategy(Strategy.DEPTHFIRST).call());

        assertEquals(2, workHead.size());
View Full Code Here

    }

    @Test
    public void testAddEmptyTree() throws Exception {
        WorkingTree workingTree = geogig.getRepository().workingTree();
        workingTree.createTypeTree(pointsName, pointsType);
        geogig.command(AddOp.class).setUpdateOnly(false).call();
        assertTrue(index.findStaged(pointsName).isPresent());
    }
View Full Code Here

            HistoryDownloader downloader, @Nullable Envelope featureFilter) throws IOException {

        Iterator<Changeset> changesets = downloader.fetchChangesets();

        GeoGIG geogig = cli.getGeogig();
        WorkingTree workingTree = geogig.getContext().workingTree();

        while (changesets.hasNext()) {
            Changeset changeset = changesets.next();
            if (changeset.isOpen()) {
                throw new CommandFailedException("Can't import past changeset " + changeset.getId()
                        + " as it is still open.");
            }
            String desc = String.format("obtaining osm changeset %,d...", changeset.getId());
            console.print(desc);
            console.flush();

            Optional<Iterator<Change>> opchanges = changeset.getChanges().get();
            if (!opchanges.isPresent()) {
                updateBranchChangeset(geogig, changeset.getId());
                console.println(" does not apply.");
                console.flush();
                continue;
            }
            Iterator<Change> changes = opchanges.get();
            console.print("applying...");
            console.flush();

            ObjectId workTreeId = workingTree.getTree().getId();
            long changeCount = insertChanges(cli, changes, featureFilter);
            console.print(String.format("Applied %,d changes, staging...", changeCount));
            console.flush();
            ObjectId afterTreeId = workingTree.getTree().getId();

            DiffObjectCount diffCount = geogig.command(DiffCount.class)
                    .setOldVersion(workTreeId.toString()).setNewVersion(afterTreeId.toString())
                    .call();
View Full Code Here

    private long insertChanges(GeogigCLI cli, final Iterator<Change> changes,
            @Nullable Envelope featureFilter) throws IOException {

        final GeoGIG geogig = cli.getGeogig();
        final Repository repository = geogig.getRepository();
        final WorkingTree workTree = repository.workingTree();

        Map<Long, Coordinate> thisChangePointCache = new LinkedHashMap<Long, Coordinate>() {
            /** serialVersionUID */
            private static final long serialVersionUID = 1277795218777240552L;

            @Override
            protected boolean removeEldestEntry(Map.Entry<Long, Coordinate> eldest) {
                return size() == 10000;
            }
        };

        long cnt = 0;

        Set<String> deletes = Sets.newHashSet();
        Multimap<String, SimpleFeature> insertsByParent = HashMultimap.create();

        while (changes.hasNext()) {
            Change change = changes.next();
            final String featurePath = featurePath(change);
            if (featurePath == null) {
                continue;// ignores relations
            }
            final String parentPath = NodeRef.parentPath(featurePath);
            if (Change.Type.delete.equals(change.getType())) {
                cnt++;
                deletes.add(featurePath);
            } else {
                final Primitive primitive = change.getNode().isPresent() ? change.getNode().get()
                        : change.getWay().get();
                final Geometry geom = parseGeometry(geogig, primitive, thisChangePointCache);
                if (geom instanceof Point) {
                    thisChangePointCache.put(Long.valueOf(primitive.getId()),
                            ((Point) geom).getCoordinate());
                }

                SimpleFeature feature = toFeature(primitive, geom);

                if (featureFilter == null
                        || featureFilter.intersects((Envelope) feature.getBounds())) {
                    insertsByParent.put(parentPath, feature);
                    cnt++;
                }
            }
        }

        for (String parentPath : insertsByParent.keySet()) {
            Collection<SimpleFeature> features = insertsByParent.get(parentPath);
            if (features.isEmpty()) {
                continue;
            }

            Iterator<? extends Feature> iterator = features.iterator();
            ProgressListener listener = new DefaultProgressListener();
            List<org.locationtech.geogig.api.Node> insertedTarget = null;
            Integer collectionSize = Integer.valueOf(features.size());
            workTree.insert(parentPath, iterator, listener, insertedTarget, collectionSize);
        }
        if (!deletes.isEmpty()) {
            workTree.delete(deletes.iterator());
        }
        return cnt;
    }
View Full Code Here

        }
    }

    @Override
    protected StatusSummary _call() {
        WorkingTree workTree = workingTree();
        StagingArea index = index();

        StatusSummary summary = new StatusSummary();

        summary.countStaged = index.countStaged(null).count();
        summary.countUnstaged = workTree.countUnstaged(null).count();
        summary.countConflicted = index.countConflicted(null);

        if (summary.countStaged > 0) {
            summary.staged = command(DiffIndex.class).setReportTrees(true);
        }
View Full Code Here

        String featureId = lines1.getIdentifier().getID();
        String path = NodeRef.appendChild(linesName, featureId);
        String featureId2 = lines2.getIdentifier().getID();
        String path2 = NodeRef.appendChild(linesName, featureId2);

        WorkingTree tree = geogig.command(RemoveOp.class).addPathToRemove(path)
                .addPathToRemove(path2).call();

        geogig.command(AddOp.class).call();

        RevCommit commit = geogig.command(CommitOp.class).setMessage("Removed lines").call();
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.repository.WorkingTree

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.