Search in sources :

Example 26 with FeatureCollection

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

the class MergeTest method buildFeatureList3.

private static FeatureCollection buildFeatureList3() throws FactoryException {
    type = createSimpleType2();
    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-21");
    myFeature1.setPropertyValue("name", 21);
    myFeature1.setPropertyValue("color", "grey");
    myFeature1.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
    myFeature1.setPropertyValue("geom3", 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-22");
    myFeature2.setPropertyValue("name", 22);
    myFeature2.setPropertyValue("color", "red");
    myFeature2.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
    myFeature2.setPropertyValue("geom3", 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-23");
    myFeature3.setPropertyValue("name", 23);
    myFeature3.setPropertyValue("color", "blue");
    myFeature3.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
    myFeature3.setPropertyValue("geom3", null);
    featureList.add(myFeature3);
    return featureList;
}
Also used : MultiPoint(org.locationtech.jts.geom.MultiPoint) FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) Coordinate(org.locationtech.jts.geom.Coordinate) LineString(org.locationtech.jts.geom.LineString) LinearRing(org.locationtech.jts.geom.LinearRing) Feature(org.opengis.feature.Feature)

Example 27 with FeatureCollection

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

the class MergeTest method testMerge.

/**
 * Merge Test with 4 FeatureCollection. 1 - base FeatureCollection 2 - FeatureCollection with same FeatureType as
 * base 3 - FeatureCollection with some attribute like base and with conversion needed 4 - FeatureCollection with
 * none attribute like base
 */
@Test
public void testMerge() throws ProcessException, NoSuchIdentifierException, FactoryException {
    // Inputs
    final FeatureCollection featureList1 = buildFeatureList1();
    final FeatureCollection featureList2 = buildFeatureList2();
    final FeatureCollection featureList3 = buildFeatureList3();
    final FeatureCollection featureList4 = buildFeatureList4();
    FeatureCollection[] FCList = new FeatureCollection[4];
    FCList[0] = featureList1;
    FCList[1] = featureList2;
    FCList[2] = featureList3;
    FCList[3] = featureList4;
    // Process
    ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, MergeDescriptor.NAME);
    ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("features_in").setValue(FCList);
    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)

Example 28 with FeatureCollection

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

the class NearestTest method testNearest.

/**
 * Test nearest process
 */
@Test
public void testNearest() throws FactoryException, ProcessException, NoSuchIdentifierException {
    // Inputs
    final FeatureCollection featureList = buildFeatureList();
    final Geometry geom = buildIntersectionGeometry();
    // Process
    ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:nearest");
    ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("feature_in").setValue(featureList);
    in.parameter("geometry_in").setValue(geom);
    org.geotoolkit.process.Process proc = desc.createProcess(in);
    // Features out
    final FeatureSet featureListOut = (FeatureSet) proc.call().parameter("feature_out").getValue();
    // Expected Features out
    final FeatureSet featureListResult = buildResultList();
    compare(featureListResult, featureListOut);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) FeatureSet(org.apache.sis.storage.FeatureSet) AbstractProcessTest(org.geotoolkit.processing.vector.AbstractProcessTest) Test(org.junit.Test)

Example 29 with FeatureCollection

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

the class NearestTest method buildFeatureList.

private static FeatureCollection buildFeatureList() throws FactoryException {
    type = createSimpleType();
    final FeatureCollection featureList = FeatureStoreUtilities.collection("nearest", type);
    final Feature feature1 = type.newInstance();
    feature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-1");
    feature1.setPropertyValue("name", "feature1");
    feature1.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(2, 2)));
    featureList.add(feature1);
    final Feature feature2 = type.newInstance();
    feature2.setPropertyValue(AttributeConvention.IDENTIFIER, "id-2");
    feature2.setPropertyValue("name", "feature2");
    feature2.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(3, 1)));
    featureList.add(feature2);
    final Feature feature3 = type.newInstance();
    feature3.setPropertyValue(AttributeConvention.IDENTIFIER, "id-3");
    feature3.setPropertyValue("name", "feature3");
    feature3.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(3, 4)));
    featureList.add(feature3);
    final Feature feature4 = type.newInstance();
    feature4.setPropertyValue(AttributeConvention.IDENTIFIER, "id-4");
    feature4.setPropertyValue("name", "feature4");
    feature4.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(5, 4)));
    featureList.add(feature4);
    final Feature feature5 = type.newInstance();
    feature5.setPropertyValue(AttributeConvention.IDENTIFIER, "id-5");
    feature5.setPropertyValue("name", "feature5");
    feature5.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(6, 2)));
    featureList.add(feature5);
    final Feature feature6 = type.newInstance();
    feature6.setPropertyValue(AttributeConvention.IDENTIFIER, "id-6");
    feature6.setPropertyValue("name", "feature6");
    feature6.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(6, 1)));
    featureList.add(feature6);
    final Feature feature7 = type.newInstance();
    feature7.setPropertyValue(AttributeConvention.IDENTIFIER, "id-7");
    feature7.setPropertyValue("name", "feature7");
    feature7.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(7, 3)));
    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 30 with FeatureCollection

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

the class NearestTest method buildResultList.

private static FeatureCollection buildResultList() throws FactoryException {
    type = createSimpleType();
    final FeatureCollection featureList = FeatureStoreUtilities.collection("IntersectTest", type);
    final Feature feature4 = type.newInstance();
    feature4.setPropertyValue(AttributeConvention.IDENTIFIER, "id-4");
    feature4.setPropertyValue("name", "feature4");
    feature4.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(5, 4)));
    featureList.add(feature4);
    final Feature feature5 = type.newInstance();
    feature5.setPropertyValue(AttributeConvention.IDENTIFIER, "id-5");
    feature5.setPropertyValue("name", "feature5");
    feature5.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(6, 2)));
    featureList.add(feature5);
    return featureList;
}
Also used : FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) Coordinate(org.locationtech.jts.geom.Coordinate) Feature(org.opengis.feature.Feature)

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