Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 @Override
 public Geometry filterInPlace(Geometry f) {
   return GeometryFactory.fromJTS(f.toJTS().getBoundary(), f.getAllAttributes());
 }