use of com.vividsolutions.jts.io.ParseException in project alliance by codice.
the class NsiliFilterFactory method convertWktToBqs.
public String convertWktToBqs(String wkt) {
WKTReader wktReader = new WKTReader(GEOMETRY_FACTORY);
Geometry geometry;
try {
geometry = wktReader.read(wkt);
} catch (ParseException e) {
LOGGER.debug("Unable to parse WKT String {}", wkt, e);
return NsiliFilterDelegate.EMPTY_STRING;
}
if (geometry.getCoordinates() == null || StringUtils.isBlank(geometry.getGeometryType())) {
return NsiliFilterDelegate.EMPTY_STRING;
}
StringBuilder result = new StringBuilder(geometry.getGeometryType().toUpperCase() + LP);
Coordinate[] coordinates = geometry.getCoordinates();
for (Coordinate coordinate : coordinates) {
result.append(coordinate.y + COMMA + coordinate.x + COMMA);
}
return result.toString().substring(0, result.toString().length() - 1) + RP;
}
use of com.vividsolutions.jts.io.ParseException in project alliance by codice.
the class ImagingChipActionProvider method hasValidLocation.
private boolean hasValidLocation(String location) {
if (StringUtils.isNotBlank(location)) {
try {
// parse the WKT location to determine if it has valid format
final WKTReader wktReader = new WKTReader(geometryFactory);
wktReader.read(location);
return true;
} catch (ParseException e) {
LOGGER.debug("Location [{}] is invalid. Cannot chip this image", location);
}
}
return false;
}
use of com.vividsolutions.jts.io.ParseException in project teiid by teiid.
the class GeometryUtils method getGeometry.
public static Geometry getGeometry(InputStream is1, Integer srid, boolean allowEwkb) throws FunctionExecutionException {
try {
WKBReader reader = new WKBReader();
Geometry jtsGeom = reader.read(new InputStreamInStream(is1));
if (!allowEwkb && (jtsGeom.getSRID() != GeometryType.UNKNOWN_SRID || (jtsGeom.getCoordinate() != null && !Double.isNaN(jtsGeom.getCoordinate().z)))) {
// $NON-NLS-1$
throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31160, "EWKB"));
}
if (srid != null) {
jtsGeom.setSRID(srid);
}
return jtsGeom;
} catch (ParseException e) {
throw new FunctionExecutionException(e);
} catch (IOException e) {
throw new FunctionExecutionException(e);
} finally {
if (is1 != null) {
try {
is1.close();
} catch (IOException e) {
}
}
}
}
use of com.vividsolutions.jts.io.ParseException in project hibernate-spatial-tutorials by maesenka.
the class EventManager method wktToGeometry.
private Geometry wktToGeometry(String wktPoint) {
WKTReader fromText = new WKTReader();
Geometry geom = null;
try {
geom = fromText.read(wktPoint);
} catch (ParseException e) {
throw new RuntimeException("Not a WKT string:" + wktPoint);
}
return geom;
}
use of com.vividsolutions.jts.io.ParseException in project ili2db by claeis.
the class PostgisColumnConverter method toIomMultiSurface.
@Override
public IomObject toIomMultiSurface(Object geomobj, String sqlAttrName, boolean is3D) throws SQLException, ConverterException {
byte[] bv = (byte[]) geomobj;
Wkb2iox conv = new Wkb2iox();
try {
return conv.read(bv);
} catch (ParseException e) {
throw new ConverterException(e);
}
}
Aggregations