use of org.openforis.idm.model.CoordinateAttribute in project collect by openforis.
the class CSVDataImportProcess method setSRSIdField.
private void setSRSIdField(Attribute<?, ?> attr, String value, long row, String colName) {
boolean valid = true;
if (StringUtils.isNotBlank(value)) {
// check SRS id validity
Survey survey = attr.getSurvey();
SpatialReferenceSystem srs = survey.getSpatialReferenceSystem(value);
if (srs == null) {
ParsingError parsingError = new ParsingError(ErrorType.INVALID_VALUE, row, colName, SRS_NOT_FOUND_MESSAGE_KEY);
parsingError.setMessageArgs(new String[] { value });
status.addParsingError(parsingError);
valid = false;
}
}
if (valid) {
Field<String> field = ((CoordinateAttribute) attr).getSrsIdField();
NodeChangeSet changes = recordUpdater.updateField(field, value);
if (nodeChangeBatchProcessor != null) {
nodeChangeBatchProcessor.add(changes, adminUser.getUsername());
}
}
}
use of org.openforis.idm.model.CoordinateAttribute in project collect by openforis.
the class DistanceCheckTest method testEvalutateDistanceCheckDestinationPoint.
@Test
public void testEvalutateDistanceCheckDestinationPoint() {
EntityBuilder.addValue(cluster, "id", new Code("001"));
Coordinate coord = Coordinate.parseCoordinate("SRID=EPSG:21035;POINT(885750 9333820)");
CoordinateAttribute vehicleLocation = EntityBuilder.addValue(cluster, "vehicle_location", coord);
CoordinateAttributeDefinition defn = vehicleLocation.getDefinition();
DistanceCheck check = (DistanceCheck) defn.getChecks().get(0);
Coordinate destinationPoint = check.evaluateDestinationPoint(vehicleLocation);
Assert.assertEquals(TEST_COORDINATE, destinationPoint);
}
use of org.openforis.idm.model.CoordinateAttribute in project collect by openforis.
the class DistanceCheckTest method testEvalutateDistanceCheckMaxDistance.
@Test
public void testEvalutateDistanceCheckMaxDistance() {
EntityBuilder.addValue(cluster, "id", new Code("001"));
Coordinate coord = Coordinate.parseCoordinate("SRID=EPSG:21035;POINT(885750 9333820)");
CoordinateAttribute vehicleLocation = EntityBuilder.addValue(cluster, "vehicle_location", coord);
CoordinateAttributeDefinition defn = vehicleLocation.getDefinition();
DistanceCheck check = (DistanceCheck) defn.getChecks().get(0);
Double maxDistance = check.evaluateMaxDistance(vehicleLocation);
Assert.assertEquals(Double.valueOf(100000d), maxDistance);
}
use of org.openforis.idm.model.CoordinateAttribute in project collect by openforis.
the class DistanceCheckTest method testWarnMaxDistance.
@Test
public void testWarnMaxDistance() {
String coordStr = "SRID=EPSG:21035;POINT(885750 9333820)";
Coordinate coord = Coordinate.parseCoordinate(coordStr);
EntityBuilder.addValue(cluster, "id", new Code("001"));
CoordinateAttribute vehicleLocation = EntityBuilder.addValue(cluster, "vehicle_location", coord);
ValidationResults results = validate(vehicleLocation);
Assert.assertFalse(containsDistanceCheck(results.getErrors()));
Assert.assertTrue(containsDistanceCheck(results.getWarnings()));
}
use of org.openforis.idm.model.CoordinateAttribute in project collect by openforis.
the class DistanceCheckTest method testErrorMaxDistance.
@Test
public void testErrorMaxDistance() {
String coordStr = "SRID=EPSG:21035;POINT(915750 9333820)";
Coordinate coord = Coordinate.parseCoordinate(coordStr);
EntityBuilder.addValue(cluster, "id", new Code("001"));
CoordinateAttribute vehicleLocation = EntityBuilder.addValue(cluster, "vehicle_location", coord);
ValidationResults results = validate(vehicleLocation);
Assert.assertTrue(containsDistanceCheck(results.getErrors()));
}
Aggregations