protected RevCommit commit(String message) { return commit(repo.context(), message); }
protected List<RevCommit> populate(boolean oneCommitPerFeature, List<Feature> features) throws Exception { List<RevCommit> commits = new ArrayList<RevCommit>(); for (Feature f : features) { insertAndAdd(f); if (oneCommitPerFeature) { commits.add(commit(f.getIdentifier().getID())); } } if (!oneCommitPerFeature) { String msg = Joiner.on(',') .join(Lists.transform(features, (f) -> f.getIdentifier().getID())); commits.add(commit(msg)); } return commits; }
protected List<RevCommit> populate(boolean oneCommitPerFeature, List<Feature> features) throws Exception { List<RevCommit> commits = new ArrayList<RevCommit>(); for (Feature f : features) { insertAndAdd(f); if (oneCommitPerFeature) { commits.add(commit(f.getIdentifier().getID())); } } if (!oneCommitPerFeature) { String msg = Joiner.on(',') .join(Lists.transform(features, (f) -> f.getIdentifier().getID())); commits.add(commit(msg)); } return commits; }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); this.worldPointsTree = repository.getTree(worldPointsLayer.getObjectId()); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); this.worldPointsTree = repository.getTree(worldPointsLayer.getObjectId()); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Test public void testBothBranchesSameGeometryChange() throws Exception { String ancestorLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195701 38.780762, -75.1195916 38.7816402, -75.1195154 38.7820072)"; String leftLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195645 38.7807768, -75.1195916 38.7816402, -75.1195841 38.7817429, -75.1195702 38.7818159, -75.1195333 38.7819121, -75.119487 38.7819971)"; String rightLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195645 38.7807768, -75.1195916 38.7816402, -75.1195841 38.7817429, -75.1195702 38.7818159, -75.1195333 38.7819121, -75.119487 38.7819971)"; final String fid = "112233"; final Feature ancestor = super.feature(linesType, fid, "secondary", 1, ancestorLine); final Feature left = super.feature(linesType, fid, "secondary", 1, leftLine); final Feature right = super.feature(linesType, fid, "primary", 1, rightLine); super.insertAndAdd(ancestor); super.commit("common ancestor"); geogig.command(BranchCreateOp.class).setName("branch").call(); super.insertAndAdd(left); super.commit("master change"); assertEquals("branch", geogig.command(CheckoutOp.class).setSource("branch").call() .getNewRef().localName()); super.insertAndAdd(right); final RevCommit branchCommit = super.commit("branch change"); geogig.command(CheckoutOp.class).setSource("master").call(); geogig.command(MergeOp.class).addCommit(branchCommit.getId()).call(); }
@Test public void testBothBranchesSameGeometryChange() throws Exception { String ancestorLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195701 38.780762, -75.1195916 38.7816402, -75.1195154 38.7820072)"; String leftLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195645 38.7807768, -75.1195916 38.7816402, -75.1195841 38.7817429, -75.1195702 38.7818159, -75.1195333 38.7819121, -75.119487 38.7819971)"; String rightLine = "LINESTRING (-75.1195282 38.7801263, -75.1195626 38.7806208, -75.1195645 38.7807768, -75.1195916 38.7816402, -75.1195841 38.7817429, -75.1195702 38.7818159, -75.1195333 38.7819121, -75.119487 38.7819971)"; final String fid = "112233"; final Feature ancestor = super.feature(linesType, fid, "secondary", 1, ancestorLine); final Feature left = super.feature(linesType, fid, "secondary", 1, leftLine); final Feature right = super.feature(linesType, fid, "primary", 1, rightLine); super.insertAndAdd(ancestor); super.commit("common ancestor"); geogig.command(BranchCreateOp.class).setName("branch").call(); super.insertAndAdd(left); super.commit("master change"); assertEquals("branch", geogig.command(CheckoutOp.class).setSource("branch").call() .getNewRef().localName()); super.insertAndAdd(right); final RevCommit branchCommit = super.commit("branch change"); geogig.command(CheckoutOp.class).setSource("master").call(); geogig.command(MergeOp.class).addCommit(branchCommit.getId()).call(); }
/** * Make sure a spatial query against a geometry attribute that does not define a CRS just * assumes the query is in the native CRS */ @Test public void testSpatialQueryOnNullCrsAttribute() throws Exception { final String typeName = "nullcrs"; final SimpleFeatureType type = DataUtilities.createType(typeName, "the_geom:Point,name:String"); assertNull(type.getGeometryDescriptor().getCoordinateReferenceSystem()); List<Feature> features = new ArrayList<>(); for (int i = 0; i < 3; i++) { Feature f = super.feature(type, String.valueOf(i), String.format("POINT(%d %d)", i, i), "f-" + i); features.add(f); } super.insert(features); super.add(); super.commit("created feature type with null CRS"); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); assertNull(source.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem()); Filter bbox; SimpleFeatureCollection coll; bbox = ff.bbox("the_geom", -0.5, -0.5, 0.5, 0.5, "EPSG:4326"); coll = source.getFeatures(bbox); assertEquals(1, coll.size()); bbox = ff.bbox("the_geom", -0.5, -0.5, 0.5, 0.5, "EPSG:3857"); coll = source.getFeatures(bbox); assertEquals(1, coll.size()); }
/** * Make sure a spatial query against a geometry attribute that does not define a CRS just * assumes the query is in the native CRS */ @Test public void testSpatialQueryOnNullCrsAttribute() throws Exception { final String typeName = "nullcrs"; final SimpleFeatureType type = DataUtilities.createType(typeName, "the_geom:Point,name:String"); assertNull(type.getGeometryDescriptor().getCoordinateReferenceSystem()); List<Feature> features = new ArrayList<>(); for (int i = 0; i < 3; i++) { Feature f = super.feature(type, String.valueOf(i), String.format("POINT(%d %d)", i, i), "f-" + i); features.add(f); } super.insert(features); super.add(); super.commit("created feature type with null CRS"); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); assertNull(source.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem()); Filter bbox; SimpleFeatureCollection coll; bbox = ff.bbox("the_geom", -0.5, -0.5, 0.5, 0.5, "EPSG:4326"); coll = source.getFeatures(bbox); assertEquals(1, coll.size()); bbox = ff.bbox("the_geom", -0.5, -0.5, 0.5, 0.5, "EPSG:3857"); coll = source.getFeatures(bbox); assertEquals(1, coll.size()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = IndexTestSupport.getPointFid(5, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 5, 10"); String fid2 = IndexTestSupport.getPointFid(35, -40); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 35, -40"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = IndexTestSupport.getPointFid(-10, 65); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted -10, 65"); repository.command(CheckoutOp.class).setSource("master").call(); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = IndexTestSupport.getPointFid(5, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 5, 10"); String fid2 = IndexTestSupport.getPointFid(35, -40); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 35, -40"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = IndexTestSupport.getPointFid(-10, 65); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted -10, 65"); repository.command(CheckoutOp.class).setSource("master").call(); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = getPointFid(0, 0); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 0, 0"); String fid2 = getPointFid(0, 5); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 0, 5"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = getPointFid(0, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted 0, 10"); repository.command(CheckoutOp.class).setSource("master").call(); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = IndexTestSupport.getPointFid(5, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 5, 10"); String fid2 = IndexTestSupport.getPointFid(35, -40); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 35, -40"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = IndexTestSupport.getPointFid(-10, 65); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted -10, 65"); repository.command(CheckoutOp.class).setSource("master").call(); this.worldPointsTree = repository.getTree(worldPointsLayer.getObjectId()); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = IndexTestSupport.getPointFid(5, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 5, 10"); String fid2 = IndexTestSupport.getPointFid(35, -40); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 35, -40"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = IndexTestSupport.getPointFid(-10, 65); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted -10, 65"); repository.command(CheckoutOp.class).setSource("master").call(); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = getPointFid(0, 0); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 0, 0"); String fid2 = getPointFid(0, 5); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 0, 5"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = getPointFid(0, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted 0, 10"); repository.command(CheckoutOp.class).setSource("master").call(); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = IndexTestSupport.getPointFid(5, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 5, 10"); String fid2 = IndexTestSupport.getPointFid(35, -40); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 35, -40"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = IndexTestSupport.getPointFid(-10, 65); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted -10, 65"); repository.command(CheckoutOp.class).setSource("master").call(); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = IndexTestSupport.getPointFid(5, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 5, 10"); String fid2 = IndexTestSupport.getPointFid(35, -40); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 35, -40"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = IndexTestSupport.getPointFid(-10, 65); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted -10, 65"); repository.command(CheckoutOp.class).setSource("master").call(); this.worldPointsTree = repository.getTree(worldPointsLayer.getObjectId()); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = IndexTestSupport.getPointFid(5, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 5, 10"); String fid2 = IndexTestSupport.getPointFid(35, -40); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 35, -40"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = IndexTestSupport.getPointFid(-10, 65); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted -10, 65"); repository.command(CheckoutOp.class).setSource("master").call(); this.worldPointsTree = repository.getTree(worldPointsLayer.getObjectId()); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); String fid1 = IndexTestSupport.getPointFid(5, 10); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid1)).call(); repository.command(BranchCreateOp.class).setName("branch1").call(); super.add(); super.commit("deleted 5, 10"); String fid2 = IndexTestSupport.getPointFid(35, -40); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid2)).call(); super.add(); super.commit("deleted 35, -40"); repository.command(CheckoutOp.class).setSource("branch1").call(); String fid3 = IndexTestSupport.getPointFid(-10, 65); repository.command(RemoveOp.class) .addPathToRemove(NodeRef.appendChild(worldPointsLayer.getName(), fid3)).call(); super.add(); super.commit("deleted -10, 65"); repository.command(CheckoutOp.class).setSource("master").call(); this.worldPointsTree = repository.getTree(worldPointsLayer.getObjectId()); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }