use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ClipTest method buildFeatureClip.
private static FeatureCollection buildFeatureClip() throws FactoryException {
type = createSimpleType();
final FeatureCollection featureList = FeatureStoreUtilities.collection("noname", type);
geometryFactory = org.geotoolkit.geometry.jts.JTS.getFactory();
Feature myFeature1 = type.newInstance();
LinearRing ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(0.0, 1.0), new Coordinate(4.0, 1.0), new Coordinate(4.0, 3.0), new Coordinate(0.0, 3.0), new Coordinate(0.0, 1.0) });
myFeature1.setPropertyValue("sis:identifier", "id-11");
myFeature1.setPropertyValue("name", "Building11");
myFeature1.setPropertyValue("height", 12);
myFeature1.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature1);
Feature myFeature2 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(3.0, 5.0), new Coordinate(4.0, 5.0), new Coordinate(4.0, 6.0), new Coordinate(3.0, 6.0), new Coordinate(3.0, 5.0) });
myFeature2.setPropertyValue("sis:identifier", "id-12");
myFeature2.setPropertyValue("name", "Building11");
myFeature2.setPropertyValue("height", 12);
myFeature2.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature2);
Feature myFeature3 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(6.0, 3.0), new Coordinate(9.0, 3.0), new Coordinate(9.0, 6.0), new Coordinate(6.0, 6.0), new Coordinate(6.0, 3.0) });
myFeature3.setPropertyValue("sis:identifier", "id-13");
myFeature3.setPropertyValue("name", "Building13");
myFeature3.setPropertyValue("height", 12);
myFeature3.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature3);
Feature myFeature4 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(10.0, 0.0), new Coordinate(11.0, 0.0), new Coordinate(11.0, 4.0), new Coordinate(10.0, 4.0), new Coordinate(10.0, 0.0) });
myFeature4.setPropertyValue("sis:identifier", "id-14");
myFeature4.setPropertyValue("name", "Building14");
myFeature4.setPropertyValue("height", 12);
myFeature4.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature4);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ClipGeometryTest method buildResultList.
private static FeatureCollection buildResultList() throws FactoryException {
type = createSimpleResultType();
final FeatureCollection featureList = FeatureStoreUtilities.collection("noname", type);
Feature myFeature1 = type.newInstance();
LinearRing ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(6.0, 3.0), new Coordinate(6.0, 4.0), new Coordinate(7.0, 4.0), new Coordinate(7.0, 3.0), new Coordinate(6.0, 3.0) });
myFeature1.setPropertyValue("sis:identifier", "id-01");
myFeature1.setPropertyValue("name", "Building1");
myFeature1.setPropertyValue("height", 12);
myFeature1.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature1);
Feature myFeature2 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(10.0, 4.0), new Coordinate(8.0, 4.0), new Coordinate(8.0, 6.0), new Coordinate(10.0, 6.0), new Coordinate(10.0, 4.0) });
myFeature2.setPropertyValue("sis:identifier", "id-02");
myFeature2.setPropertyValue("name", "Building2");
myFeature2.setPropertyValue("height", 12);
myFeature2.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature2);
Feature myFeature3 = type.newInstance();
myFeature3.setPropertyValue("sis:identifier", "id-03");
myFeature3.setPropertyValue("name", "Building3");
myFeature3.setPropertyValue("height", 12);
myFeature3.setPropertyValue("position", geometryFactory.createLineString(new Coordinate[] { new Coordinate(10.0, 1.0), new Coordinate(6.0, 1.0) }));
featureList.add(myFeature3);
Feature myFeature4 = type.newInstance();
myFeature4.setPropertyValue("sis:identifier", "id-04");
myFeature4.setPropertyValue("name", "Building4");
myFeature4.setPropertyValue("height", 12);
myFeature4.setPropertyValue("position", geometryFactory.createPoint(new Coordinate(3.0, 6.0)));
featureList.add(myFeature4);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ConvexHullTest method testConvexHull.
@Test
public void testConvexHull() throws ProcessException, NoSuchIdentifierException, FactoryException {
// Inputs
final FeatureCollection featureList = buildFeatureList();
// Process
ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:convexhull");
ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("feature_in").setValue(featureList);
org.geotoolkit.process.Process proc = desc.createProcess(in);
// Geometry out
final Geometry resultGeom = (Geometry) proc.call().parameter("geometry_out").getValue();
// Expected Features out
final Geometry geomteryResult1 = buildGeometryResult1();
assertTrue(geomteryResult1.equals(resultGeom));
// assertEquals(geomteryResult1, resultGeom);
// select the second feature geometry
ProcessDescriptor desc2 = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:convexhull");
ParameterValueGroup in2 = desc2.getInputDescriptor().createValue();
in2.parameter("feature_in").setValue(featureList);
in2.parameter("geometry_name").setValue("geom2");
org.geotoolkit.process.Process proc2 = desc.createProcess(in2);
// Geometry out
final Geometry resultGeom2 = (Geometry) proc2.call().parameter("geometry_out").getValue();
// Expected Features out
final Geometry geomteryResult2 = buildGeometryResult2();
assertTrue(geomteryResult2.equals(resultGeom2));
// assertEquals(geomteryResult2, resultGeom2);
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ConvexHullTest method buildFeatureList.
private static FeatureCollection buildFeatureList() throws FactoryException {
type = createSimpleType();
final FeatureCollection featureList = FeatureStoreUtilities.collection("noname", type);
Feature myFeature1 = type.newInstance();
LinearRing ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(3.0, 3.0), new Coordinate(3.0, 4.0), new Coordinate(4.0, 4.0), new Coordinate(4.0, 3.0), new Coordinate(3.0, 3.0) });
myFeature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-01");
myFeature1.setPropertyValue("name", "feature1");
myFeature1.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature1.setPropertyValue("geom2", geometryFactory.createPoint(new Coordinate(3.5, 3.5)));
featureList.add(myFeature1);
Feature myFeature2 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(5.0, 6.0), new Coordinate(5.0, 7.0), new Coordinate(6.0, 7.0), new Coordinate(6.0, 6.0), new Coordinate(5.0, 6.0) });
MultiPoint multPt = geometryFactory.createMultiPoint(new Coordinate[] { new Coordinate(5.0, 4.0), new Coordinate(3.0, 6.0), new Coordinate(4.0, 7.0), new Coordinate(5.5, 6.5) });
myFeature2.setPropertyValue(AttributeConvention.IDENTIFIER, "id-02");
myFeature2.setPropertyValue("name", "feature2");
myFeature2.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature2.setPropertyValue("geom2", multPt);
featureList.add(myFeature2);
Feature myFeature3 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(9.0, 4.0), new Coordinate(9.0, 5.0), new Coordinate(11.0, 5.0), new Coordinate(11.0, 4.0), new Coordinate(9.0, 4.0) });
LineString line = geometryFactory.createLineString(new Coordinate[] { new Coordinate(7.0, 0.0), new Coordinate(9.0, 3.0) });
myFeature3.setPropertyValue(AttributeConvention.IDENTIFIER, "id-03");
myFeature3.setPropertyValue("name", "feature3");
myFeature3.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature3.setPropertyValue("geom2", line);
featureList.add(myFeature3);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class DifferenceTest method buildFeatureClip.
private static FeatureCollection buildFeatureClip() throws FactoryException {
type = createSimpleType();
final FeatureCollection featureList = FeatureStoreUtilities.collection("noname", type);
geometryFactory = org.geotoolkit.geometry.jts.JTS.getFactory();
Feature myFeature1 = type.newInstance();
LinearRing ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(0.0, 1.0), new Coordinate(4.0, 1.0), new Coordinate(4.0, 3.0), new Coordinate(0.0, 3.0), new Coordinate(0.0, 1.0) });
myFeature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-11");
myFeature1.setPropertyValue("name", "Building11");
myFeature1.setPropertyValue("height", 12);
myFeature1.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature1);
Feature myFeature2 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(3.0, 5.0), new Coordinate(4.0, 5.0), new Coordinate(4.0, 6.0), new Coordinate(3.0, 6.0), new Coordinate(3.0, 5.0) });
myFeature2.setPropertyValue(AttributeConvention.IDENTIFIER, "id-12");
myFeature2.setPropertyValue("name", "Building11");
myFeature2.setPropertyValue("height", 12);
myFeature2.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature2);
Feature myFeature3 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(6.0, 3.0), new Coordinate(9.0, 3.0), new Coordinate(9.0, 6.0), new Coordinate(6.0, 6.0), new Coordinate(6.0, 3.0) });
myFeature3.setPropertyValue(AttributeConvention.IDENTIFIER, "id-13");
myFeature3.setPropertyValue("name", "Building13");
myFeature3.setPropertyValue("height", 12);
myFeature3.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature3);
Feature myFeature4 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(10.0, 0.0), new Coordinate(11.0, 0.0), new Coordinate(11.0, 4.0), new Coordinate(10.0, 4.0), new Coordinate(10.0, 0.0) });
myFeature4.setPropertyValue(AttributeConvention.IDENTIFIER, "id-14");
myFeature4.setPropertyValue("name", "Building14");
myFeature4.setPropertyValue("height", 12);
myFeature4.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature4);
return featureList;
}
Aggregations