use of datawave.data.type.util.AbstractGeometry in project datawave by NationalSecurityAgency.
the class GeoWaveFunctions method getGeometryFromFieldValue.
private static Geometry getGeometryFromFieldValue(Object fieldValue) {
Geometry geometry = null;
if (fieldValue instanceof Geometry) {
geometry = (Geometry) fieldValue;
} else if (fieldValue instanceof GeoNormalizer.GeoPoint) {
geometry = geoPointToGeometry((GeoNormalizer.GeoPoint) fieldValue);
} else if (fieldValue instanceof String) {
geometry = parseGeometry((String) fieldValue);
} else if (fieldValue instanceof ValueTuple) {
ValueTuple t = (ValueTuple) fieldValue;
Object o = t.second();
if (o instanceof AbstractGeometryType) {
AbstractGeometryType<?> gt = (AbstractGeometryType<?>) o;
geometry = ((AbstractGeometry<?>) gt.getDelegate()).getJTSGeometry();
} else if (o instanceof GeoType) {
geometry = parseGeometryFromGeoType(ValueTuple.getNormalizedStringValue(fieldValue));
}
} else if (fieldValue instanceof FunctionalSet) {
FunctionalSet<?> funcSet = (FunctionalSet<?>) fieldValue;
Geometry[] geometries = funcSet.stream().map(GeoWaveFunctions::getGeometryFromFieldValue).toArray(Geometry[]::new);
geometry = new GeometryCollection(geometries, geometryFactory);
}
if (geometry == null) {
throw new IllegalArgumentException("Field Value:" + fieldValue + " cannot be recognized as a geometry");
}
return geometry;
}
Aggregations