use of org.openforis.idm.geospatial.CoordinateOperations in project collect by openforis.
the class DistanceCheck method evaluate.
@Override
public ValidationResultFlag evaluate(CoordinateAttribute coordinateAttr) {
CoordinateOperations coordinateOperations = getCoordinateOperations(coordinateAttr);
if (coordinateOperations == null) {
return ValidationResultFlag.OK;
}
try {
ExpressionEvaluator expressionEvaluator = getExpressionEvaluator(coordinateAttr);
boolean valid = expressionEvaluator.evaluateBoolean(coordinateAttr.getParent(), coordinateAttr, getExpression());
return ValidationResultFlag.valueOf(valid, this.getFlag());
} catch (InvalidExpressionException e) {
if (LOG.isInfoEnabled()) {
LOG.info("Unable to evaluate distance check ", e);
}
return ValidationResultFlag.OK;
}
}
use of org.openforis.idm.geospatial.CoordinateOperations in project collect by openforis.
the class GeoDataController method createCoordinateValuesKML.
@RequestMapping(value = "survey/{surveyId}/data/coordinatesvalues.kml", method = GET, produces = KML_CONTENT_TYPE)
public void createCoordinateValuesKML(@PathVariable("surveyId") int surveyId, @RequestParam int stepNum, @RequestParam int coordinateAttributeId, HttpServletResponse response) throws Exception {
CollectSurvey survey = surveyManager.getById(surveyId);
CoordinateAttributeDefinition nodeDef = (CoordinateAttributeDefinition) survey.getSchema().getDefinitionById(coordinateAttributeId);
RecordCoordinatesKmlGeneratorJob job = new RecordCoordinatesKmlGeneratorJob();
job.setRecordManager(recordManager);
RecordFilter filter = new RecordFilter(survey);
job.setRecordFilter(filter);
job.setNodeDefinition(nodeDef);
job.setOutput(response.getOutputStream());
CoordinateOperations coordinateOperations = survey.getContext().getCoordinateOperations();
coordinateOperations.registerSRS(survey.getSpatialReferenceSystems());
job.setCoordinateOperations(coordinateOperations);
jobManager.start(job, false);
}
use of org.openforis.idm.geospatial.CoordinateOperations in project collect by openforis.
the class GeoFunctions method distance.
/**
* Calculates the orthodromic distance between 2 coordinates (in meters)
*/
protected static Double distance(ExpressionContext context, Object from, Object to) {
if (from == null || to == null) {
return null;
}
Coordinate fromC = from instanceof Coordinate ? (Coordinate) from : Coordinate.parseCoordinate(from);
if (fromC == null || !fromC.isComplete()) {
return null;
}
Coordinate toC = to instanceof Coordinate ? (Coordinate) to : Coordinate.parseCoordinate(to);
if (toC == null || !toC.isComplete()) {
return null;
}
CoordinateOperations coordinateOperations = getSurvey(context).getContext().getCoordinateOperations();
if (coordinateOperations == null) {
return null;
} else {
try {
double distance = coordinateOperations.orthodromicDistance(fromC, toC);
return distance;
} catch (CoordinateOperationException e) {
return null;
}
}
}
use of org.openforis.idm.geospatial.CoordinateOperations in project collect by openforis.
the class GeoFunctions method latLong.
protected static Coordinate latLong(ExpressionContext expressionContext, Coordinate coordinate) {
if (coordinate == null || !coordinate.isComplete()) {
return null;
}
Survey survey = getSurvey(expressionContext);
CoordinateOperations coordinateOperations = survey.getContext().getCoordinateOperations();
if (coordinateOperations == null) {
return null;
} else {
return coordinateOperations.convertToWgs84(coordinate);
}
}
Aggregations