use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class MaxLimitTest method testLimit.
@Test
public void testLimit() throws ProcessException, NoSuchIdentifierException, FactoryException {
// Inputs
final FeatureCollection featureList = buildFeatureList();
// Process
ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:maxlimit");
ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("feature_in").setValue(featureList);
in.parameter("max_in").setValue(5);
org.geotoolkit.process.Process proc = desc.createProcess(in);
// Features out
final FeatureCollection featureListOut = (FeatureCollection) proc.call().parameter("feature_out").getValue();
assertEquals(5, featureListOut.size());
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class MaxLimitTest method buildFeatureList.
private static FeatureCollection buildFeatureList() throws FactoryException {
type = createSimpleResultType();
final FeatureCollection featureList = FeatureStoreUtilities.collection("noname", type);
Feature myFeature = type.newInstance();
LinearRing ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(4, 7), new Coordinate(6, 7), new Coordinate(6, 5), new Coordinate(4, 5), new Coordinate(4, 7) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-01 U id-11");
myFeature.setPropertyValue("name", "feature1");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(3, 5), new Coordinate(3, 7), new Coordinate(4, 7), new Coordinate(4, 5), new Coordinate(3, 5) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-01");
myFeature.setPropertyValue("name", "feature1");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(7, 5), new Coordinate(8, 5), new Coordinate(8, 4), new Coordinate(7, 4), new Coordinate(7, 5) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-03 U id-12");
myFeature.setPropertyValue("name", "feature3");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(6, 4), new Coordinate(6, 5), new Coordinate(7, 5), new Coordinate(7, 4), new Coordinate(6, 4) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-03 U id-11");
myFeature.setPropertyValue("name", "feature3");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(6, 2), new Coordinate(6, 4), new Coordinate(8, 4), new Coordinate(8, 2), new Coordinate(6, 2) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-03 U id-13");
myFeature.setPropertyValue("name", "feature3");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(7, 7), new Coordinate(8, 7), new Coordinate(8, 5), new Coordinate(7, 5), new Coordinate(7, 7) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-02 U id-12");
myFeature.setPropertyValue("name", "feature2");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(6, 5), new Coordinate(6, 7), new Coordinate(7, 7), new Coordinate(7, 5), new Coordinate(6, 5) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-02 U id-11");
myFeature.setPropertyValue("name", "feature2");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(2, 3), new Coordinate(2, 4), new Coordinate(3, 4), new Coordinate(3, 3), new Coordinate(2, 3) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-04");
myFeature.setPropertyValue("name", "feature4");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(7, 7), new Coordinate(7, 8), new Coordinate(9, 8), new Coordinate(9, 4), new Coordinate(8, 4), new Coordinate(8, 5), new Coordinate(8, 7), new Coordinate(7, 7) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-12");
myFeature.setPropertyValue("name", "feature12");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(8, 4), new Coordinate(9, 4), new Coordinate(9, 2), new Coordinate(8, 2), new Coordinate(8, 4) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-13");
myFeature.setPropertyValue("name", "feature13");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(4, 2), new Coordinate(4, 3), new Coordinate(5, 3), new Coordinate(5, 2), new Coordinate(4, 2) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-14");
myFeature.setPropertyValue("name", "feature14");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(4, 4), new Coordinate(4, 5), new Coordinate(6, 5), new Coordinate(6, 4), new Coordinate(4, 4) });
LinearRing ring2 = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(4, 7), new Coordinate(4, 8), new Coordinate(7, 8), new Coordinate(7, 7), new Coordinate(6, 7), new Coordinate(4, 7) });
Polygon poly1 = geometryFactory.createPolygon(ring, null);
Polygon poly2 = geometryFactory.createPolygon(ring2, null);
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-11");
myFeature.setPropertyValue("name", "feature11");
myFeature.setPropertyValue("geom1", geometryFactory.createMultiPolygon(new Polygon[] { poly1, poly2 }));
featureList.add(myFeature);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class MergeTest method buildFeatureList2.
private static FeatureCollection buildFeatureList2() throws FactoryException {
type = createSimpleType();
final FeatureCollection featureList = FeatureStoreUtilities.collection("noname", type);
Feature myFeature1 = type.newInstance();
LinearRing ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(1.0, 4.0), new Coordinate(1.0, 5.0), new Coordinate(2.0, 5.0), new Coordinate(2.0, 4.0), new Coordinate(1.0, 4.0) });
MultiPoint multPt = geometryFactory.createMultiPoint(new Coordinate[] { // nothing
new Coordinate(1.0, 6.0), // intersection with a point
new Coordinate(3.0, 6.0), // intersection with a polygon
new Coordinate(3.5, 3.5) });
myFeature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-11");
myFeature1.setPropertyValue("name", "feature11");
myFeature1.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature1.setPropertyValue("geom2", multPt);
featureList.add(myFeature1);
Feature myFeature2 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(4.0, 2.0), new Coordinate(4.0, 5.0), new Coordinate(7.0, 5.0), new Coordinate(7.0, 2.0), new Coordinate(4.0, 2.0) });
LineString line = geometryFactory.createLineString(new Coordinate[] { new Coordinate(8.0, 4.5), new Coordinate(11.0, 4.5) });
myFeature2.setPropertyValue(AttributeConvention.IDENTIFIER, "id-12");
myFeature2.setPropertyValue("name", "feature12");
myFeature2.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature2.setPropertyValue("geom2", line);
featureList.add(myFeature2);
Feature myFeature3 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(0.0, 0.0), new Coordinate(0.0, 8.0), new Coordinate(10.0, 8.0), new Coordinate(10.0, 0.0), new Coordinate(0.0, 0.0) });
myFeature3.setPropertyValue(AttributeConvention.IDENTIFIER, "id-13");
myFeature3.setPropertyValue("name", "feature13");
myFeature3.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature3.setPropertyValue("geom2", null);
featureList.add(myFeature3);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class MergeTest method buildResultList.
private static FeatureCollection buildResultList() 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);
// /////////////////////////////////////////////////////////// 2nd FeatureCollection
myFeature1 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(1.0, 4.0), new Coordinate(1.0, 5.0), new Coordinate(2.0, 5.0), new Coordinate(2.0, 4.0), new Coordinate(1.0, 4.0) });
multPt = geometryFactory.createMultiPoint(new Coordinate[] { new Coordinate(1.0, 6.0), new Coordinate(3.0, 6.0), new Coordinate(3.5, 3.5) });
myFeature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-11");
myFeature1.setPropertyValue("name", "feature11");
myFeature1.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature1.setPropertyValue("geom2", multPt);
featureList.add(myFeature1);
myFeature2 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(4.0, 2.0), new Coordinate(4.0, 5.0), new Coordinate(7.0, 5.0), new Coordinate(7.0, 2.0), new Coordinate(4.0, 2.0) });
line = geometryFactory.createLineString(new Coordinate[] { new Coordinate(8.0, 4.5), new Coordinate(11.0, 4.5) });
myFeature2.setPropertyValue(AttributeConvention.IDENTIFIER, "id-12");
myFeature2.setPropertyValue("name", "feature12");
myFeature2.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature2.setPropertyValue("geom2", line);
featureList.add(myFeature2);
myFeature3 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(0.0, 0.0), new Coordinate(0.0, 8.0), new Coordinate(10.0, 8.0), new Coordinate(10.0, 0.0), new Coordinate(0.0, 0.0) });
myFeature3.setPropertyValue(AttributeConvention.IDENTIFIER, "id-13");
myFeature3.setPropertyValue("name", "feature13");
myFeature3.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature3.setPropertyValue("geom2", null);
featureList.add(myFeature3);
// //////////////////////////////////////////////////////////////////// 3rd FeatureCollection
myFeature1 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(1.0, 4.0), new Coordinate(1.0, 5.0), new Coordinate(2.0, 5.0), new Coordinate(2.0, 4.0), new Coordinate(1.0, 4.0) });
myFeature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-21");
myFeature1.setPropertyValue("name", "21");
myFeature1.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature1.setPropertyValue("geom2", null);
featureList.add(myFeature1);
myFeature2 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(4.0, 2.0), new Coordinate(4.0, 5.0), new Coordinate(7.0, 5.0), new Coordinate(7.0, 2.0), new Coordinate(4.0, 2.0) });
myFeature2.setPropertyValue(AttributeConvention.IDENTIFIER, "id-22");
myFeature2.setPropertyValue("name", "22");
myFeature2.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature2.setPropertyValue("geom2", null);
featureList.add(myFeature2);
myFeature3 = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(0.0, 0.0), new Coordinate(0.0, 8.0), new Coordinate(10.0, 8.0), new Coordinate(10.0, 0.0), new Coordinate(0.0, 0.0) });
myFeature3.setPropertyValue(AttributeConvention.IDENTIFIER, "id-23");
myFeature3.setPropertyValue("name", "23");
myFeature3.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature3.setPropertyValue("geom2", null);
featureList.add(myFeature3);
// //////////////////////////////////////////////////////////////////// 4th FeatureCollection
myFeature1 = type.newInstance();
myFeature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-31");
myFeature1.setPropertyValue("name", null);
myFeature1.setPropertyValue("geom1", null);
myFeature1.setPropertyValue("geom2", null);
featureList.add(myFeature1);
myFeature2 = type.newInstance();
myFeature2.setPropertyValue(AttributeConvention.IDENTIFIER, "id-32");
myFeature2.setPropertyValue("name", null);
myFeature2.setPropertyValue("geom1", null);
myFeature2.setPropertyValue("geom2", null);
featureList.add(myFeature2);
myFeature3 = type.newInstance();
myFeature3.setPropertyValue(AttributeConvention.IDENTIFIER, "id-33");
myFeature3.setPropertyValue("name", null);
myFeature3.setPropertyValue("geom1", null);
myFeature3.setPropertyValue("geom2", null);
featureList.add(myFeature3);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class MergeTest method buildFeatureList1.
private static FeatureCollection buildFeatureList1() 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;
}
Aggregations