use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ClipTest method buildFeatureList.
private static FeatureCollection buildFeatureList() 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(6.0, 3.0), new Coordinate(7.0, 3.0), new Coordinate(7.0, 4.0), new Coordinate(6.0, 4.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(8.0, 4.0), new Coordinate(11.0, 4.0), new Coordinate(11.0, 7.0), new Coordinate(8.0, 7.0), new Coordinate(8.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();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(6.0, -2.0), new Coordinate(13.0, -2.0), new Coordinate(13.0, 1.0), new Coordinate(6.0, 1.0), new Coordinate(6.0, -2.0) });
myFeature3.setPropertyValue("sis:identifier", "id-03");
myFeature3.setPropertyValue("name", "Building3");
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(0.0, 6.0), new Coordinate(3.0, 6.0), new Coordinate(3.0, 9.0), new Coordinate(0.0, 9.0), new Coordinate(0.0, 6.0) });
myFeature4.setPropertyValue("sis:identifier", "id-04");
myFeature4.setPropertyValue("name", "Building4");
myFeature4.setPropertyValue("height", 12);
myFeature4.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature4);
Feature myFeature5 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(-4.0, 1.0), new Coordinate(-1.0, 1.0), new Coordinate(-1.0, 3.0), new Coordinate(-4.0, 3.0), new Coordinate(-4.0, 1.0) });
myFeature5.setPropertyValue("sis:identifier", "id-05");
myFeature5.setPropertyValue("name", "Building5");
myFeature5.setPropertyValue("height", 12);
myFeature5.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature5);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ClipTest method buildResultList.
private static FeatureCollection buildResultList() throws FactoryException {
type = createSimpleResultType();
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(7.0, 3.0), new Coordinate(6.0, 3.0), new Coordinate(6.0, 4.0), new Coordinate(7.0, 4.0), new Coordinate(7.0, 3.0) });
myFeature1.setPropertyValue("sis:identifier", "id-01");
Polygon poly = geometryFactory.createPolygon(ring, null);
myFeature1.setPropertyValue("name", "Building1");
myFeature1.setPropertyValue("height", 12);
myFeature1.setPropertyValue("position", poly);
featureList.add(myFeature1);
Feature myFeature2 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(9.0, 4.0), new Coordinate(8.0, 4.0), new Coordinate(8.0, 6.0), new Coordinate(9.0, 6.0), new Coordinate(9.0, 4.0) });
poly = geometryFactory.createPolygon(ring, null);
LineString lineString = geometryFactory.createLineString(new Coordinate[] { new Coordinate(10.0, 4.0), new Coordinate(11.0, 4.0) });
myFeature2.setPropertyValue("sis:identifier", "id-02");
myFeature2.setPropertyValue("name", "Building2");
myFeature2.setPropertyValue("height", 12);
myFeature2.setPropertyValue("position", geometryFactory.createGeometryCollection(new Geometry[] { poly, lineString }));
featureList.add(myFeature2);
Feature myFeature3 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(10.0, 1.0), new Coordinate(11.0, 1.0), new Coordinate(11.0, 0.0), new Coordinate(10.0, 0.0), new Coordinate(10.0, 1.0) });
poly = geometryFactory.createPolygon(ring, null);
myFeature3.setPropertyValue("sis:identifier", "id-03");
myFeature3.setPropertyValue("name", "Building3");
myFeature3.setPropertyValue("height", 12);
myFeature3.setPropertyValue("position", poly);
featureList.add(myFeature3);
Feature myFeature4 = type.newInstance();
myFeature4.setPropertyValue("sis:identifier", "id-04");
Point pt = geometryFactory.createPoint(new Coordinate(3.0, 6.0));
myFeature4.setPropertyValue("name", "Building4");
myFeature4.setPropertyValue("height", 12);
myFeature4.setPropertyValue("position", pt);
featureList.add(myFeature4);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ClipGeometryTest method testClipGeometry.
@Test
public void testClipGeometry() throws ProcessException, NoSuchIdentifierException, FactoryException {
// Inputs
final FeatureCollection featureList = buildFeatureList();
final Geometry geometryClip = buildGeometryClip();
// Process
ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:clipGeometry");
ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("feature_in").setValue(featureList);
in.parameter("clip_geometry_in").setValue(geometryClip);
org.geotoolkit.process.Process proc = desc.createProcess(in);
// Features out
final FeatureCollection featureListOut = (FeatureCollection) proc.call().parameter("feature_out").getValue();
// Expected Features out
final FeatureCollection featureListResult = buildResultList();
compare(featureListResult, featureListOut);
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ClipGeometryTest 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(6.0, 3.0), new Coordinate(7.0, 3.0), new Coordinate(7.0, 4.0), new Coordinate(6.0, 4.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(8.0, 4.0), new Coordinate(11.0, 4.0), new Coordinate(11.0, 7.0), new Coordinate(8.0, 7.0), new Coordinate(8.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();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(6.0, -2.0), new Coordinate(13.0, -2.0), new Coordinate(13.0, 1.0), new Coordinate(6.0, 1.0), new Coordinate(6.0, -2.0) });
myFeature3.setPropertyValue("sis:identifier", "id-03");
myFeature3.setPropertyValue("name", "Building3");
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(0.0, 6.0), new Coordinate(3.0, 6.0), new Coordinate(3.0, 9.0), new Coordinate(0.0, 9.0), new Coordinate(0.0, 6.0) });
myFeature4.setPropertyValue("sis:identifier", "id-04");
myFeature4.setPropertyValue("name", "Building4");
myFeature4.setPropertyValue("height", 12);
myFeature4.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature4);
Feature myFeature5 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(-4.0, 1.0), new Coordinate(-1.0, 1.0), new Coordinate(-1.0, 3.0), new Coordinate(-4.0, 3.0), new Coordinate(-4.0, 1.0) });
myFeature5.setPropertyValue("sis:identifier", "id-05");
myFeature5.setPropertyValue("name", "Building5");
myFeature5.setPropertyValue("height", 12);
myFeature5.setPropertyValue("position", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature5);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class DifferenceTest method testDifference.
@Test
public void testDifference() throws ProcessException, NoSuchIdentifierException, FactoryException {
// Inputs
final FeatureCollection featureList = buildFeatureList();
final FeatureCollection featuresClip = buildFeatureClip();
// Process
ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:difference");
ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("feature_in").setValue(featureList);
in.parameter("feature_diff").setValue(featuresClip);
org.geotoolkit.process.Process proc = desc.createProcess(in);
// Features out
final FeatureCollection featureListOut = (FeatureCollection) proc.call().parameter("feature_out").getValue();
// Expected Features out
final FeatureCollection featureListResult = buildResultList();
compare(featureListResult, featureListOut);
}
Aggregations