Search in sources :

Example 36 with FeatureCollection

use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.

the class SpatialJoinTest method buildResultInter2.

private static FeatureSet buildResultInter2() throws FactoryException {
    type = createSimpleTypeResult();
    final FeatureCollection featureList = FeatureStoreUtilities.collection("SJ_Type1_SJ_Type2", type);
    final Feature feature1 = type.newInstance();
    feature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-01");
    feature1.setPropertyValue("name", "Field");
    feature1.setPropertyValue("age", 1);
    LinearRing ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(40, 30), new Coordinate(40, 50), new Coordinate(70, 50), new Coordinate(70, 30), new Coordinate(40, 30) });
    feature1.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
    feature1.setPropertyValue("type", null);
    feature1.setPropertyValue("age_SJ_Type2", null);
    featureList.add(feature1);
    return featureList;
}
Also used : FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Feature(org.opengis.feature.Feature)

Example 37 with FeatureCollection

use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.

the class SpatialJoinTest method buildResultInter.

private static FeatureSet buildResultInter() throws FactoryException {
    type = createSimpleTypeResult();
    final FeatureCollection featureList = FeatureStoreUtilities.collection("SJ_Type1_SJ_Type2", type);
    final Feature feature1 = type.newInstance();
    feature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-01_id-12");
    feature1.setPropertyValue("name", "Field");
    feature1.setPropertyValue("age", 1);
    LinearRing ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(4, 3), new Coordinate(4, 5), new Coordinate(7, 5), new Coordinate(7, 3), new Coordinate(4, 3) });
    feature1.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
    feature1.setPropertyValue("type", "something2");
    feature1.setPropertyValue("age_SJ_Type2", 2);
    featureList.add(feature1);
    return featureList;
}
Also used : FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Feature(org.opengis.feature.Feature)

Example 38 with FeatureCollection

use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.

the class SpatialJoinTest method buildFeatureList2.

private static FeatureSet buildFeatureList2() throws FactoryException {
    type = createSimpleType2();
    final FeatureCollection featureList = FeatureStoreUtilities.collection("source", type);
    final Feature feature1 = type.newInstance();
    feature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-11");
    feature1.setPropertyValue("type", "Tree1");
    feature1.setPropertyValue("age", 220);
    feature1.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(2, 1)));
    featureList.add(feature1);
    final Feature feature2 = type.newInstance();
    feature2.setPropertyValue(AttributeConvention.IDENTIFIER, "id-12");
    feature2.setPropertyValue("type", "Tree2");
    feature2.setPropertyValue("age", 100);
    feature2.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(3, 6)));
    featureList.add(feature2);
    final Feature feature3 = type.newInstance();
    feature3.setPropertyValue(AttributeConvention.IDENTIFIER, "id-13");
    feature3.setPropertyValue("type", "Tree3");
    feature3.setPropertyValue("age", 5);
    feature3.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(5, 5)));
    featureList.add(feature3);
    final Feature feature4 = type.newInstance();
    feature4.setPropertyValue(AttributeConvention.IDENTIFIER, "id-14");
    feature4.setPropertyValue("type", "Tree4");
    feature4.setPropertyValue("age", 40);
    feature4.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(6, 2)));
    featureList.add(feature4);
    final Feature feature5 = type.newInstance();
    feature5.setPropertyValue(AttributeConvention.IDENTIFIER, "id-15");
    feature5.setPropertyValue("type", "Tree5");
    feature5.setPropertyValue("age", 57);
    feature5.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(9, 5)));
    featureList.add(feature5);
    final Feature feature6 = type.newInstance();
    feature6.setPropertyValue(AttributeConvention.IDENTIFIER, "id-16");
    feature6.setPropertyValue("type", "Tree6");
    feature6.setPropertyValue("age", 68);
    feature6.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(9, 3)));
    featureList.add(feature6);
    final Feature feature7 = type.newInstance();
    feature7.setPropertyValue(AttributeConvention.IDENTIFIER, "id-17");
    feature7.setPropertyValue("type", "Tree7");
    feature7.setPropertyValue("age", 94);
    feature7.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(11, 2)));
    featureList.add(feature7);
    return featureList;
}
Also used : FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) Coordinate(org.locationtech.jts.geom.Coordinate) Feature(org.opengis.feature.Feature)

Example 39 with FeatureCollection

use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.

the class AffineTransformTest method testAffineTransform.

@Test
public void testAffineTransform() throws ProcessException, NoSuchIdentifierException, FactoryException {
    // Inputs
    final FeatureCollection featureList = buildFeatureList();
    final AffineTransform transform = new AffineTransform();
    transform.setToTranslation(100, 100);
    // Process
    final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:affinetransform");
    final ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("feature_in").setValue(featureList);
    in.parameter("transform_in").setValue(transform);
    final 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);
}
Also used : FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) AffineTransform(java.awt.geom.AffineTransform) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) AbstractProcessTest(org.geotoolkit.processing.vector.AbstractProcessTest) Test(org.junit.Test)

Example 40 with FeatureCollection

use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.

the class ClipTest method testClip.

@Test
public void testClip() throws ProcessException, NoSuchIdentifierException, FactoryException {
    // Inputs
    final FeatureCollection featureList = buildFeatureList();
    final FeatureCollection featuresClip = buildFeatureClip();
    // Process
    ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:clip");
    ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("feature_in").setValue(featureList);
    in.parameter("feature_clip").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);
}
Also used : FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) AbstractProcessTest(org.geotoolkit.processing.vector.AbstractProcessTest) Test(org.junit.Test)

Aggregations

FeatureCollection (org.geotoolkit.storage.feature.FeatureCollection)131 Feature (org.opengis.feature.Feature)75 Test (org.junit.Test)49 Coordinate (org.locationtech.jts.geom.Coordinate)49 LinearRing (org.locationtech.jts.geom.LinearRing)39 Query (org.geotoolkit.storage.feature.query.Query)31 FeatureType (org.opengis.feature.FeatureType)27 FeatureIterator (org.geotoolkit.storage.feature.FeatureIterator)24 LineString (org.locationtech.jts.geom.LineString)23 MultiPoint (org.locationtech.jts.geom.MultiPoint)16 ProcessDescriptor (org.geotoolkit.process.ProcessDescriptor)15 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)15 Geometry (org.locationtech.jts.geom.Geometry)14 AbstractProcessTest (org.geotoolkit.processing.vector.AbstractProcessTest)13 Session (org.geotoolkit.storage.feature.session.Session)12 CheckCloseFeatureIterator (org.geotoolkit.storage.feature.CheckCloseFeatureIterator)10 Point (org.locationtech.jts.geom.Point)10 GenericName (org.opengis.util.GenericName)10 NoSuchElementException (java.util.NoSuchElementException)8 File (java.io.File)7