use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ReprojectTest 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));
// sfb.set("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) });
myFeature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-02");
myFeature2.setPropertyValue("name", "feature2");
myFeature2.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
// sfb.set("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));
// sfb.set("geom2", line);
featureList.add(myFeature3);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class ReprojectTest method testReprojection.
@Test
public void testReprojection() throws FactoryException, ProcessException, NoSuchIdentifierException {
// Inputs
final FeatureCollection featureList = buildFeatureList();
// Process
ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:reproject");
ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("feature_in").setValue(featureList);
in.parameter("crs_in").setValue(CRS.forCode("EPSG:27582"));
org.geotoolkit.process.Process proc = desc.createProcess(in);
// FeatureCollection out
final FeatureCollection resultFC = (FeatureCollection) proc.call().parameter("feature_out").getValue();
assertEquals(featureList.getIdentifier(), resultFC.getIdentifier());
assertEquals(resultFC.size(), resultFC.size());
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class SpatialJoinTest method buildFeatureListInter1_2.
private static FeatureSet buildFeatureListInter1_2() throws FactoryException {
type = createSimpleType1();
final FeatureCollection featureList = FeatureStoreUtilities.collection("target", 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));
featureList.add(feature1);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class SpatialJoinTest method buildResultNear.
private static FeatureSet buildResultNear() throws FactoryException {
type = createSimpleTypeResult();
final FeatureCollection featureList = FeatureStoreUtilities.collection("SJ_Type1_SJ_Type2", type);
final Feature feature1 = type.newInstance();
feature1.setPropertyValue(AttributeConvention.IDENTIFIER, "id-1_id-11");
feature1.setPropertyValue("name", "Human1");
feature1.setPropertyValue("age", 20);
feature1.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(3, 2)));
feature1.setPropertyValue("type", "Tree1");
feature1.setPropertyValue("age_SJ_Type2", 220);
featureList.add(feature1);
final Feature feature2 = type.newInstance();
feature2.setPropertyValue(AttributeConvention.IDENTIFIER, "id-2_id-12");
feature2.setPropertyValue("name", "Human2");
feature2.setPropertyValue("age", 10);
feature2.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(3, 5)));
feature2.setPropertyValue("type", "Tree2");
feature2.setPropertyValue("age_SJ_Type2", 100);
featureList.add(feature2);
final Feature feature3 = type.newInstance();
feature3.setPropertyValue(AttributeConvention.IDENTIFIER, "id-3_id-13");
feature3.setPropertyValue("name", "Human3");
feature3.setPropertyValue("age", 35);
feature3.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(6, 6)));
feature3.setPropertyValue("type", "Tree3");
feature3.setPropertyValue("age_SJ_Type2", 5);
featureList.add(feature3);
final Feature feature4 = type.newInstance();
feature4.setPropertyValue(AttributeConvention.IDENTIFIER, "id-4_id-14");
feature4.setPropertyValue("name", "Human4");
feature4.setPropertyValue("age", 40);
feature4.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(6, 2)));
feature4.setPropertyValue("type", "Tree4");
feature4.setPropertyValue("age_SJ_Type2", 40);
featureList.add(feature4);
final Feature feature5 = type.newInstance();
feature5.setPropertyValue(AttributeConvention.IDENTIFIER, "id-5_id-13");
feature5.setPropertyValue("name", "Human5");
feature5.setPropertyValue("age", 23);
feature5.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(7, 4)));
feature5.setPropertyValue("type", "Tree3");
feature5.setPropertyValue("age_SJ_Type2", 5);
featureList.add(feature5);
final Feature feature6 = type.newInstance();
feature6.setPropertyValue(AttributeConvention.IDENTIFIER, "id-6_id-16");
feature6.setPropertyValue("name", "Human6");
feature6.setPropertyValue("age", 32);
feature6.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(9, 4)));
feature6.setPropertyValue("type", "Tree6");
feature6.setPropertyValue("age_SJ_Type2", 68);
featureList.add(feature6);
final Feature feature7 = type.newInstance();
feature7.setPropertyValue(AttributeConvention.IDENTIFIER, "id-7_id-16");
feature7.setPropertyValue("name", "Human7");
feature7.setPropertyValue("age", 28);
feature7.setPropertyValue("geom1", geometryFactory.createPoint(new Coordinate(9, 1)));
feature7.setPropertyValue("type", "Tree6");
feature7.setPropertyValue("age_SJ_Type2", 68);
featureList.add(feature7);
return featureList;
}
use of org.geotoolkit.storage.feature.FeatureCollection in project geotoolkit by Geomatys.
the class UnionTest method buildResultList.
private static FeatureCollection buildResultList() 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-id-11");
myFeature.setPropertyValue("name", "feature1");
myFeature.setPropertyValue("color", "red");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature.setPropertyValue("att", 20);
featureList.add(myFeature);
myFeature = type.newInstance();
LineString str = geometryFactory.createLineString(new Coordinate[] { new Coordinate(3, 5), new Coordinate(3, 6) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-01-id-15");
myFeature.setPropertyValue("name", "feature1");
myFeature.setPropertyValue("color", "grey");
myFeature.setPropertyValue("geom1", str);
myFeature.setPropertyValue("att", 12);
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(3, 5), new Coordinate(3, 6), 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("color", null);
myFeature.setPropertyValue("att", null);
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-id-12");
myFeature.setPropertyValue("name", "feature3");
myFeature.setPropertyValue("color", "blue");
myFeature.setPropertyValue("att", 20);
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-id-11");
myFeature.setPropertyValue("name", "feature3");
myFeature.setPropertyValue("color", "red");
myFeature.setPropertyValue("att", 20);
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-id-13");
myFeature.setPropertyValue("name", "feature3");
myFeature.setPropertyValue("color", "grey");
myFeature.setPropertyValue("att", 10);
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-id-12");
myFeature.setPropertyValue("name", "feature2");
myFeature.setPropertyValue("color", "blue");
myFeature.setPropertyValue("att", 20);
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-id-11");
myFeature.setPropertyValue("name", "feature2");
myFeature.setPropertyValue("color", "red");
myFeature.setPropertyValue("att", 20);
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("color", null);
myFeature.setPropertyValue("att", null);
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
featureList.add(myFeature);
myFeature = type.newInstance();
// POLYGON ((8 5, 8 7, 7 7, 7 8, 9 8, 9 4, 8 4, 8 5))
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(8, 5), new Coordinate(8, 7), new Coordinate(7, 7), new Coordinate(7, 8), new Coordinate(9, 8), new Coordinate(9, 4), new Coordinate(8, 4), new Coordinate(8, 5) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-12");
myFeature.setPropertyValue("name", "feature12");
myFeature.setPropertyValue("color", "blue");
myFeature.setPropertyValue("att", 20);
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("color", "grey");
myFeature.setPropertyValue("att", 10);
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("color", "grey");
myFeature.setPropertyValue("att", 12);
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(6, 7), new Coordinate(4, 7), new Coordinate(4, 8), new Coordinate(7, 8), new Coordinate(7, 7), new Coordinate(6, 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("color", "red");
myFeature.setPropertyValue("att", 20);
myFeature.setPropertyValue("geom1", geometryFactory.createMultiPolygon(new Polygon[] { poly1, poly2 }));
featureList.add(myFeature);
myFeature = type.newInstance();
ring = geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(2.0, 5.0), new Coordinate(2.0, 6.0), new Coordinate(3.0, 6.0), new Coordinate(3.0, 5.0), new Coordinate(2.0, 5.0) });
myFeature.setPropertyValue(AttributeConvention.IDENTIFIER, "id-15");
myFeature.setPropertyValue("name", "feature15");
myFeature.setPropertyValue("color", "grey");
myFeature.setPropertyValue("geom1", geometryFactory.createPolygon(ring, null));
myFeature.setPropertyValue("att", 12);
featureList.add(myFeature);
return featureList;
}
Aggregations