use of org.opengis.feature.GeometryAttribute in project GeoGig by boundlessgeo.
the class GeogigSimpleFeature method getDefaultGeometryProperty.
@Override
public GeometryAttribute getDefaultGeometryProperty() {
GeometryDescriptor geometryDescriptor = featureType.getGeometryDescriptor();
GeometryAttribute geometryAttribute = null;
if (geometryDescriptor != null) {
Object defaultGeometry = getDefaultGeometry();
geometryAttribute = new GeometryAttributeImpl(defaultGeometry, geometryDescriptor, null);
}
return geometryAttribute;
}
use of org.opengis.feature.GeometryAttribute in project GeoGig by boundlessgeo.
the class MappingRule method hasCompatibleGeometryType.
private boolean hasCompatibleGeometryType(Feature feature) {
getFeatureType();
GeomRestriction restriction = getGeomRestriction();
GeometryAttribute property = feature.getDefaultGeometryProperty();
Geometry geom = (Geometry) property.getValue();
if (geom.getClass().equals(Point.class)) {
return geometryType == Point.class;
} else {
if (geometryType.equals(Point.class)) {
return false;
}
Coordinate[] coords = geom.getCoordinates();
if (geometryType.equals(Polygon.class) && coords.length < 3) {
return false;
}
boolean isClosed = coords[0].equals(coords[coords.length - 1]);
if (isClosed && restriction.equals(GeomRestriction.ONLY_OPEN_LINES)) {
return false;
}
if (!isClosed && restriction.equals(GeomRestriction.ONLY_CLOSED_LINES)) {
return false;
}
return true;
}
}
use of org.opengis.feature.GeometryAttribute in project ddf by codice.
the class TestPubSubOgcFilter method generateSampleFeature.
private SimpleFeature generateSampleFeature() {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("PubSubFeature");
// add properties
b.add("name", String.class);
b.add("classification", Integer.class);
b.add("height", Double.class);
com.vividsolutions.jts.geom.GeometryFactory geoFactory = JTSFactoryFinder.getGeometryFactory(null);
// add geo
b.setCRS(DefaultGeographicCRS.WGS84);
b.add("geo", Point.class);
final SimpleFeatureType pubSubFeature = b.buildFeatureType();
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(pubSubFeature);
featureBuilder.set("name", "FirstFeature");
featureBuilder.set("classification", 10);
featureBuilder.set("height", 5.8);
com.vividsolutions.jts.geom.Point point = geoFactory.createPoint(new Coordinate(-112, 28));
featureBuilder.set("geo", point);
SimpleFeature feature = featureBuilder.buildFeature("f1");
// it looks like if I add an attribute into the feature that is of geometry type, it
// automatically
// becomes the default geo property. If no geo is specified, getDefaultGeometryProperty
// returns null
GeometryAttribute defaultGeo = feature.getDefaultGeometryProperty();
LOGGER.debug("geo name: {}", defaultGeo.getName());
LOGGER.debug("geo: {}", defaultGeo);
return feature;
}
use of org.opengis.feature.GeometryAttribute in project GeoGig by boundlessgeo.
the class ShpExport method getTransformingFunction.
private Function<Feature, Optional<Feature>> getTransformingFunction(final SimpleFeatureType featureType) {
Function<Feature, Optional<Feature>> function = new Function<Feature, Optional<Feature>>() {
@Override
@Nullable
public Optional<Feature> apply(@Nullable Feature feature) {
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
for (Property property : feature.getProperties()) {
if (property instanceof GeometryAttribute) {
builder.set(featureType.getGeometryDescriptor().getName(), property.getValue());
} else {
String name = property.getName().getLocalPart();
if (name.length() > 10) {
name = name.substring(0, 10);
}
builder.set(name, property.getValue());
}
}
Feature modifiedFeature = builder.buildFeature(feature.getIdentifier().getID());
return Optional.fromNullable(modifiedFeature);
}
};
return function;
}
use of org.opengis.feature.GeometryAttribute in project GeoGig by boundlessgeo.
the class ShpExportDiff method getTransformingFunction.
private Function<Feature, Optional<Feature>> getTransformingFunction(final SimpleFeatureType featureType) {
Function<Feature, Optional<Feature>> function = new Function<Feature, Optional<Feature>>() {
@Override
@Nullable
public Optional<Feature> apply(@Nullable Feature feature) {
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
for (Property property : feature.getProperties()) {
if (property instanceof GeometryAttribute) {
builder.set(featureType.getGeometryDescriptor().getName(), property.getValue());
} else {
builder.set(property.getName(), property.getValue());
}
}
Feature modifiedFeature = builder.buildFeature(feature.getIdentifier().getID());
return Optional.fromNullable(modifiedFeature);
}
};
return function;
}
Aggregations