if(Point.class.isAssignableFrom(target) || MultiPoint.class.isAssignableFrom(target)
|| GeometryCollection.class.equals(target)) {
result = clipped;
} else if(MultiLineString.class.isAssignableFrom(target) || LineString.class.isAssignableFrom(target)) {
final List<LineString> geoms = new ArrayList<LineString>();
clipped.apply(new GeometryComponentFilter() {
@Override
public void filter(Geometry geom) {
if(geom instanceof LineString) {
geoms.add((LineString) geom);
}
}
});
if(geoms.size() == 0) {
result = null;
} else {
LineString[] lsArray = (LineString[]) geoms.toArray(new LineString[geoms.size()]);
result = geom.getFactory().createMultiLineString(lsArray);
}
} else if(MultiPolygon.class.isAssignableFrom(target) || Polygon.class.isAssignableFrom(target)) {
final List<Polygon> geoms = new ArrayList<Polygon>();
clipped.apply(new GeometryComponentFilter() {
@Override
public void filter(Geometry geom) {
if(geom instanceof Polygon) {
geoms.add((Polygon) geom);