public static WritableGeometry convertToGeometry(SimpleFeature feature) { // Translate the SimpleFeature geometry to JTS geometry com.vividsolutions.jts.geom.Geometry jtsGeometry = (com.vividsolutions.jts.geom.Geometry) feature.getDefaultGeometry(); // Then generate a MrGeo WritableGeometry from the JTS geometry WritableGeometry geom = GeometryFactory.fromJTS(jtsGeometry); // Now copy over the attributes to the MrGeo WritableGeometry List<AttributeDescriptor> descriptors = feature.getFeatureType().getAttributeDescriptors(); for (AttributeDescriptor desc : descriptors) { String localName = desc.getLocalName(); Object attrValue = feature.getAttribute(localName); if (attrValue != null) { String strValue = attrValue.toString(); geom.setAttribute(localName, strValue); } } return geom; }
@Override public Geometry filterInPlace(Geometry f) { return GeometryFactory.fromJTS(f.toJTS().getBoundary(), f.getAllAttributes()); }