points1 = feature(pointsType, idP1, "StringProp1_1", new Integer(1000), "POINT(1 1)"); points1_modified = feature(pointsType, idP1, "StringProp1_1a", new Integer(1001), "POINT(1 2)"); points1B = feature(modifiedPointsType, idP1, "StringProp1_1", new Integer(1000), "POINT(1 1)", "ExtraString"); points1B_modified = feature(modifiedPointsType, idP1, "StringProp1_1a", new Integer(1001), "POINT(1 2)", "ExtraStringB"); points2 = feature(pointsType, idP2, "StringProp1_2", new Integer(2000), "POINT(2 2)"); points3 = feature(pointsType, idP3, "StringProp1_3", new Integer(3000), "POINT(3 3)"); lines1 = feature(linesType, idL1, "StringProp2_1", new Integer(1000), "LINESTRING (1 1, 2 2)"); lines2 = feature(linesType, idL2, "StringProp2_2", new Integer(2000), "LINESTRING (3 3, 4 4)"); lines3 = feature(linesType, idL3, "StringProp2_3", new Integer(3000), "LINESTRING (5 5, 6 6)"); poly1 = feature(polyType, idPG1, "StringProp3_1", new Integer(1000), "POLYGON ((1 1, 2 2, 3 3, 4 4, 1 1))"); poly2 = feature(polyType, idPG2, "StringProp3_2", new Integer(2000), "POLYGON ((6 6, 7 7, 8 8, 9 9, 6 6))"); poly3 = feature(polyType, idPG3, "StringProp3_3", new Integer(3000), "POLYGON ((11 11, 12 12, 13 13, 14 14, 11 11))"); points2_modified = feature(pointsType, idP2, "StringProp1_2a", new Integer(2001), "POINT(2 3)");
points1 = feature(pointsType, idP1, "StringProp1_1", new Integer(1000), "POINT(1 1)"); points1_modified = feature(pointsType, idP1, "StringProp1_1a", new Integer(1001), "POINT(1 2)"); points1B = feature(modifiedPointsType, idP1, "StringProp1_1", new Integer(1000), "POINT(1 1)", "ExtraString"); points1B_modified = feature(modifiedPointsType, idP1, "StringProp1_1a", new Integer(1001), "POINT(1 2)", "ExtraStringB"); points2 = feature(pointsType, idP2, "StringProp1_2", new Integer(2000), "POINT(2 2)"); points3 = feature(pointsType, idP3, "StringProp1_3", new Integer(3000), "POINT(3 3)"); lines1 = feature(linesType, idL1, "StringProp2_1", new Integer(1000), "LINESTRING (1 1, 2 2)"); lines2 = feature(linesType, idL2, "StringProp2_2", new Integer(2000), "LINESTRING (3 3, 4 4)"); lines3 = feature(linesType, idL3, "StringProp2_3", new Integer(3000), "LINESTRING (5 5, 6 6)"); poly1 = feature(polyType, idPG1, "StringProp3_1", new Integer(1000), "POLYGON ((1 1, 2 2, 3 3, 4 4, 1 1))"); poly2 = feature(polyType, idPG2, "StringProp3_2", new Integer(2000), "POLYGON ((6 6, 7 7, 8 8, 9 9, 6 6))"); poly3 = feature(polyType, idPG3, "StringProp3_3", new Integer(3000), "POLYGON ((11 11, 12 12, 13 13, 14 14, 11 11))"); points2_modified = feature(pointsType, idP2, "StringProp1_2a", new Integer(2001), "POINT(2 3)");
private Node feature(ObjectStore db, String idPrefix, int index) { final String id = idPrefix + "." + index; final Feature feature; feature = super.feature(pointsType, id, id, index, point(index)); RevFeature revFeature = RevFeatureBuilder.build(feature); db.put(revFeature); Envelope bounds = (Envelope) feature.getBounds(); return Node.create(id, revFeature.getId(), ObjectId.NULL, TYPE.FEATURE, bounds); }
private Node feature(ObjectStore db, String idPrefix, int index) { final String id = idPrefix + "." + index; final Feature feature; feature = super.feature(pointsType, id, id, index, point(index)); RevFeature revFeature = RevFeature.builder().build(feature); db.put(revFeature); Envelope bounds = (Envelope) feature.getBounds(); return RevObjectFactory.defaultInstance().createNode(id, revFeature.getId(), ObjectId.NULL, TYPE.FEATURE, bounds, null); }
protected FeatureInfo featureInfo(SimpleFeatureType type, String id, Object... values) { RevFeature feature = RevFeatureBuilder.build(feature(type, id, values)); RevFeatureType ftype = RevFeatureTypeBuilder.build(type); repo.objectDatabase().put(ftype); String path = NodeRef.appendChild(type.getName().getLocalPart(), id); return FeatureInfo.insert(feature, ftype.getId(), path); }
@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()); }
protected FeatureInfo featureInfo(SimpleFeatureType type, String id, Object... values) { RevFeature feature = RevFeature.builder().build(feature(type, id, values)); RevFeatureType ftype = RevFeatureType.builder().type(type).build(); repo.objectDatabase().put(ftype); String path = NodeRef.appendChild(type.getName().getLocalPart(), id); return FeatureInfo.insert(feature, ftype.getId(), path); }