use of com.vividsolutions.jts.io.WKTReader 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.WKTReader in project alliance by codice.
the class ChipServiceImplTest method setUp.
@Before
public void setUp() throws IOException, ParseException {
this.chipService = new ChipServiceImpl();
this.inputImage = ImageIO.read(getInputStream(OVERVIEW_FILE));
this.wktReader = new WKTReader();
}
use of com.vividsolutions.jts.io.WKTReader 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.WKTReader 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.WKTReader in project spatial-portal by AtlasOfLivingAustralia.
the class Util method getBoundingBox.
public static List<Double> getBoundingBox(String wkt) {
try {
WKTReader wktReader = new WKTReader();
com.vividsolutions.jts.geom.Geometry g = wktReader.read(wkt);
List<Double> bbox = new ArrayList<Double>();
bbox.add(g.getEnvelopeInternal().getMinX());
bbox.add(g.getEnvelopeInternal().getMinY());
bbox.add(g.getEnvelopeInternal().getMaxX());
bbox.add(g.getEnvelopeInternal().getMaxY());
return bbox;
} catch (Exception e) {
return Util.getBoundingBox(CommonData.WORLD_WKT);
}
}
Aggregations