Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.GeoGIG


        };
        Context injector = Guice.createInjector(
                Modules.override(new GeogigModule()).with(new MemoryModule(testPlatform)))
                .getInstance(Context.class);

        fakeGeogig = new GeoGIG(injector, workingDirectory);
        assertNotNull(fakeGeogig.getOrCreateRepository());
        command = fakeGeogig.command(ParseTimestamp.class);
    }
View Full Code Here


        Platform testPlatform = new TestPlatform(workingDirectory);
        Context injector = Guice.createInjector(
                Modules.override(new GeogigModule()).with(new MemoryModule(testPlatform)))
                .getInstance(Context.class);

        geogit = new GeoGIG(injector);
        assertNotNull(geogit.getOrCreateRepository());
        diffTree = geogit.command(DiffTree.class);

        SimpleFeatureType ft = DataUtilities.createType("points",
                "sp:String,ip:Integer,pp:Point:srid=3857");
View Full Code Here

    @Override
    public void run(CommandContext context) {
        if (this.getTransactionId() != null) {
            throw new CommandSpecException("Tried to start a transaction within a transaction.");
        }
        final GeoGIG geogig = context.getGeoGIG();

        final GeogigTransaction transaction = geogig.command(TransactionBegin.class).call();

        context.setResponseContent(new CommandResponse() {

            @Override
            public void write(ResponseWriter out) throws Exception {
View Full Code Here

    @Override
    public void run(CommandContext context) {
        if (commitId.equals(ObjectId.NULL.toString())) {
            throw new CommandSpecException("No commitId was given.");
        }
        final GeoGIG geogig = context.getGeoGIG();
        RevCommit commit = geogig.getRepository().getCommit(ObjectId.valueOf(commitId));
        final List<RevCommit> history = Lists.newLinkedList();

        List<CommitNode> nodes = Lists.newLinkedList();
        CommitNode node = new CommitNode(commit, 1);
        nodes.add(node);

        while (!nodes.isEmpty()) {
            node = nodes.remove(0);
            if (!history.contains(node.commit)) {
                history.add(node.commit);
            }
            if (this.depth == 0 || node.depth < this.depth) {
                for (ObjectId id : node.commit.getParentIds()) {
                    nodes.add(new CommitNode(geogig.getRepository().getCommit(id), node.depth + 1));
                }
            }
        }

        final Iterator<RevCommit> historyIterator = history.iterator();
View Full Code Here

        String mappingFilename = OSMMap.class.getResource("nodes_mapping_with_aliases.json")
                .getFile();
        File mappingFile = new File(mappingFilename);
        cli.execute("osm", "import", file.getAbsolutePath(), "--mapping",
                mappingFile.getAbsolutePath());
        GeoGIG geogig = cli.newGeoGIG();
        Optional<RevFeature> revFeature = geogig.command(RevObjectParse.class)
                .setRefSpec("WORK_HEAD:busstops/507464799").call(RevFeature.class);
        assertTrue(revFeature.isPresent());
        geogig.getRepository().workingTree().delete("node");
        Optional<RevTree> tree = geogig.command(RevObjectParse.class).setRefSpec("WORK_HEAD:node")
                .call(RevTree.class);
        assertFalse(tree.isPresent());
        geogig.close();
    }
View Full Code Here

    }

    @Test
    public void testUnMapping() throws Exception {
        cli.execute("osm", "unmap", "busstops");
        GeoGIG geogig = cli.newGeoGIG();
        Optional<RevTree> tree = geogig.command(RevObjectParse.class).setRefSpec("HEAD:node")
                .call(RevTree.class);
        assertTrue(tree.isPresent());
        assertTrue(tree.get().size() > 0);
        Optional<RevFeature> unmapped = geogig.command(RevObjectParse.class)
                .setRefSpec("HEAD:node/507464799").call(RevFeature.class);
        assertTrue(unmapped.isPresent());
        ImmutableList<Optional<Object>> values = unmapped.get().getValues();
        assertEquals("POINT (7.1959361 50.739397)", values.get(6).get().toString());
        assertEquals(
                "VRS:gemeinde:BONN|VRS:ortsteil:Hoholz|VRS:ref:68566|bus:yes|highway:bus_stop|name:Gielgen|public_transport:platform",
                values.get(3).get().toString());
        geogig.close();
    }
View Full Code Here

    public void test() throws Exception {
        cli.execute("config", "user.name", "Gabriel Roldan");
        cli.execute("config", "user.email", "groldan@boundlessgeo.com");
        cli.execute("osm", "import-history", fakeOsmApiUrl, "--to", "10");

        GeoGIG geogig = cli.getGeogig();
        List<DiffEntry> changes = ImmutableList.copyOf(geogig.command(DiffOp.class)
                .setOldVersion("HEAD~2").setNewVersion("HEAD~1").call());
        assertEquals(1, changes.size());
        DiffEntry entry = changes.get(0);
        assertEquals(ChangeType.MODIFIED, entry.changeType());
        assertEquals("node/20", entry.getOldObject().path());
        assertEquals("node/20", entry.getNewObject().path());

        Optional<RevFeature> oldRevFeature = geogig.command(RevObjectParse.class)
                .setObjectId(entry.getOldObject().objectId()).call(RevFeature.class);
        Optional<RevFeature> newRevFeature = geogig.command(RevObjectParse.class)
                .setObjectId(entry.getNewObject().objectId()).call(RevFeature.class);
        assertTrue(oldRevFeature.isPresent());
        assertTrue(newRevFeature.isPresent());

        Optional<RevFeatureType> type = geogig.command(RevObjectParse.class)
                .setObjectId(entry.getOldObject().getMetadataId()).call(RevFeatureType.class);
        assertTrue(type.isPresent());

        FeatureType featureType = type.get().type();
View Full Code Here

        String filename = OSMImportOp.class.getResource("ways.xml").getFile();
        File file = new File(filename);
        cli.execute("osm", "import", file.getAbsolutePath());
        cli.execute("add");
        cli.execute("commit", "-m", "message");
        GeoGIG geogig = cli.newGeoGIG();
        Optional<RevTree> tree = geogig.command(RevObjectParse.class).setRefSpec("HEAD:node")
                .call(RevTree.class);
        assertTrue(tree.isPresent());
        assertTrue(tree.get().size() > 0);
        tree = geogig.command(RevObjectParse.class).setRefSpec("HEAD:way").call(RevTree.class);
        assertTrue(tree.isPresent());
        assertTrue(tree.get().size() > 0);
        // map
        String mappingFilename = OSMMap.class.getResource("mapping.json").getFile();
        File mappingFile = new File(mappingFilename);
        cli.execute("osm", "map", mappingFile.getAbsolutePath());
        // check that a feature was correctly mapped
        Optional<RevFeature> revFeature = geogig.command(RevObjectParse.class)
                .setRefSpec("HEAD:onewaystreets/31045880").call(RevFeature.class);
        assertTrue(revFeature.isPresent());
        ImmutableList<Optional<Object>> values = revFeature.get().getValues();
        String wkt = "LINESTRING (7.1923367 50.7395887, 7.1923127 50.7396946, 7.1923444 50.7397419, 7.1924199 50.7397781)";
        assertEquals(wkt, values.get(2).get().toString());
        assertEquals("345117525;345117526;1300224327;345117527", values.get(3).get());
        assertEquals("yes", values.get(1).get());
        // check that a feature was correctly ignored
        revFeature = geogig.command(RevObjectParse.class).setRefSpec("HEAD:onewaystreets/31347480")
                .call(RevFeature.class);
        assertFalse(revFeature.isPresent());
        geogig.close();
    }
View Full Code Here

        String filename = OSMImportOp.class.getResource("ways.xml").getFile();
        File file = new File(filename);
        cli.execute("osm", "import", file.getAbsolutePath());
        cli.execute("add");
        cli.execute("commit", "-m", "message");
        GeoGIG geogig = cli.newGeoGIG();
        Optional<RevTree> tree = geogig.command(RevObjectParse.class).setRefSpec("HEAD:node")
                .call(RevTree.class);
        assertTrue(tree.isPresent());
        assertTrue(tree.get().size() > 0);
        tree = geogig.command(RevObjectParse.class).setRefSpec("HEAD:way").call(RevTree.class);
        assertTrue(tree.isPresent());
        assertTrue(tree.get().size() > 0);
        String mappingFilename = OSMMap.class.getResource("no_filter_mapping.json").getFile();
        File mappingFile = new File(mappingFilename);
        cli.execute("osm", "map", mappingFile.getAbsolutePath());
        Iterator<NodeRef> allways = geogig.command(LsTreeOp.class).setReference("HEAD:all_ways")
                .call();
        ArrayList<NodeRef> listAllways = Lists.newArrayList(allways);
        assertEquals(4, listAllways.size());
        geogig.close();
    }
View Full Code Here

        String filename = OSMImportOp.class.getResource("ways.xml").getFile();
        File file = new File(filename);
        cli.execute("osm", "import", file.getAbsolutePath());
        cli.execute("add");
        cli.execute("commit", "-m", "message");
        GeoGIG geogig = cli.newGeoGIG();
        Optional<RevTree> tree = geogig.command(RevObjectParse.class).setRefSpec("HEAD:node")
                .call(RevTree.class);
        assertTrue(tree.isPresent());
        assertTrue(tree.get().size() > 0);
        tree = geogig.command(RevObjectParse.class).setRefSpec("HEAD:way").call(RevTree.class);
        assertTrue(tree.isPresent());
        assertTrue(tree.get().size() > 0);
        // map
        String mappingFilename = OSMMapTest.class.getResource("mapping_exclude_missing_tag.json")
                .getFile();
        File mappingFile = new File(mappingFilename);
        cli.execute("osm", "map", mappingFile.getAbsolutePath());
        // check that a feature was correctly mapped
        Optional<RevFeature> revFeature = geogig.command(RevObjectParse.class)
                .setRefSpec("HEAD:namedhighways/2059114068").call(RevFeature.class);
        assertTrue(revFeature.isPresent());
        // check that a feature was correctly ignored
        revFeature = geogig.command(RevObjectParse.class).setRefSpec("HEAD:namedhighways/81953612")
                .call(RevFeature.class);
        assertFalse(revFeature.isPresent());
        geogig.close();

    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.GeoGIG

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.