use of org.geotoolkit.process.ProcessException in project geotoolkit by Geomatys.
the class DifferenceProcess method execute.
@Override
protected void execute() throws ProcessException {
try {
final Geometry geom1 = inputParameters.getValue(DifferenceDescriptor.GEOM1);
Geometry geom2 = inputParameters.getValue(DifferenceDescriptor.GEOM2);
Geometry result = JTS.getFactory().buildGeometry(Collections.emptyList());
// ensure geometries are in the same CRS
final CoordinateReferenceSystem resultCRS = JTS.getCommonCRS(geom1, geom2);
if (JTS.isConversionNeeded(geom1, geom2)) {
geom2 = JTS.convertToCRS(geom2, resultCRS);
}
result = (Geometry) geom1.difference(geom2);
if (resultCRS != null) {
JTS.setCRS(result, resultCRS);
}
outputParameters.getOrCreate(DifferenceDescriptor.RESULT_GEOM).setValue(result);
} catch (Exception ex) {
throw new ProcessException(ex.getMessage(), this, ex);
}
}
use of org.geotoolkit.process.ProcessException in project geotoolkit by Geomatys.
the class EnvelopeProcess method execute.
@Override
protected void execute() throws ProcessException {
try {
final Geometry geom = inputParameters.getValue(EnvelopeDescriptor.GEOM);
final CoordinateReferenceSystem geomCRS = JTS.findCoordinateReferenceSystem(geom);
final Geometry result = geom.getEnvelope();
JTS.setCRS(result, geomCRS);
outputParameters.getOrCreate(EnvelopeDescriptor.RESULT_GEOM).setValue(result);
} catch (NoSuchAuthorityCodeException ex) {
throw new ProcessException(ex.getMessage(), this, ex);
} catch (FactoryException ex) {
throw new ProcessException(ex.getMessage(), this, ex);
}
}
use of org.geotoolkit.process.ProcessException in project geotoolkit by Geomatys.
the class EqualsExactProcess method execute.
@Override
protected void execute() throws ProcessException {
try {
final Geometry geom1 = inputParameters.getValue(GEOM1);
Geometry geom2 = inputParameters.getValue(GEOM2);
// ensure geometries are in the same CRS
final CoordinateReferenceSystem resultCRS = JTS.getCommonCRS(geom1, geom2);
if (JTS.isConversionNeeded(geom1, geom2)) {
geom2 = JTS.convertToCRS(geom2, resultCRS);
}
final Boolean result;
if (inputParameters.getValue(TOLERANCE) != null) {
final Double tolerance = inputParameters.getValue(TOLERANCE);
result = (Boolean) geom1.equalsExact(geom2, tolerance);
} else {
result = (Boolean) geom1.equalsExact(geom2);
}
outputParameters.getOrCreate(RESULT).setValue(result);
} catch (TransformException ex) {
throw new ProcessException(ex.getMessage(), this, ex);
} catch (FactoryException ex) {
throw new ProcessException(ex.getMessage(), this, ex);
}
}
use of org.geotoolkit.process.ProcessException in project geotoolkit by Geomatys.
the class IntersectionProcess method execute.
@Override
protected void execute() throws ProcessException {
try {
final Geometry geom1 = inputParameters.getValue(GEOM1);
Geometry geom2 = inputParameters.getValue(GEOM2);
// ensure geometries are in the same CRS
final CoordinateReferenceSystem resultCRS = JTS.getCommonCRS(geom1, geom2);
if (JTS.isConversionNeeded(geom1, geom2)) {
geom2 = JTS.convertToCRS(geom2, resultCRS);
}
final Geometry result = (Geometry) geom1.intersection(geom2);
if (resultCRS != null) {
JTS.setCRS(result, resultCRS);
}
outputParameters.getOrCreate(RESULT_GEOM).setValue(result);
} catch (Exception ex) {
throw new ProcessException(ex.getMessage(), this, ex);
}
}
use of org.geotoolkit.process.ProcessException in project geotoolkit by Geomatys.
the class CreateDBProcess method execute.
@Override
protected void execute() throws ProcessException {
ArgumentChecks.ensureNonNull("inputParameters", inputParameters);
final String dbURL = (String) inputParameters.parameter(CreateDBDescriptor.DBURL.getName().getCode()).getValue();
final String user = (String) inputParameters.parameter(CreateDBDescriptor.USER.getName().getCode()).getValue();
final String password = (String) inputParameters.parameter(CreateDBDescriptor.PASSWORD.getName().getCode()).getValue();
final DefaultDataSource ds = new DefaultDataSource(dbURL);
try {
final EPSGFactory installer = new EPSGFactory(Collections.singletonMap("dataSource", ds));
try (Connection c = ds.getConnection(user, password)) {
installer.install(c);
}
} catch (FactoryException | SQLException ex) {
throw new ProcessException(ex.getMessage(), this, ex);
}
}
Aggregations