use of org.openforis.idm.metamodel.CoordinateAttributeDefinition 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.metamodel.CoordinateAttributeDefinition 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.metamodel.CoordinateAttributeDefinition in project collect by openforis.
the class CoordinateValidator method evaluate.
@Override
public ValidationResultFlag evaluate(CoordinateAttribute node) {
Coordinate coordinate = node.getValue();
CoordinateAttributeDefinition definition = node.getDefinition();
List<SpatialReferenceSystem> srs = definition.getSurvey().getSpatialReferenceSystems();
boolean valid = coordinate.getX() != null && coordinate.getY() != null && isSrsIdValid(srs, coordinate.getSrsId());
if (valid) {
valid = node.getSurveyContext().getCoordinateOperations().validate(coordinate);
}
return ValidationResultFlag.valueOf(valid);
}
use of org.openforis.idm.metamodel.CoordinateAttributeDefinition in project collect by openforis.
the class NodeDefinitionProxy method fromList.
static List<NodeDefinitionProxy> fromList(EntityDefinitionProxy parent, List<? extends NodeDefinition> list) {
List<NodeDefinitionProxy> proxies = new ArrayList<NodeDefinitionProxy>();
if (list != null) {
for (NodeDefinition n : list) {
NodeDefinitionProxy p = null;
CollectSurvey survey = (CollectSurvey) n.getSurvey();
UIOptions uiOptions = survey.getUIOptions();
boolean hidden = uiOptions.isHidden(n);
if (!hidden) {
if (n instanceof AttributeDefinition) {
if (n instanceof BooleanAttributeDefinition) {
p = new BooleanAttributeDefinitionProxy(parent, (BooleanAttributeDefinition) n);
} else if (n instanceof CodeAttributeDefinition) {
p = new CodeAttributeDefinitionProxy(parent, (CodeAttributeDefinition) n);
} else if (n instanceof CoordinateAttributeDefinition) {
p = new CoordinateAttributeDefinitionProxy(parent, (CoordinateAttributeDefinition) n);
} else if (n instanceof DateAttributeDefinition) {
p = new DateAttributeDefinitionProxy(parent, (DateAttributeDefinition) n);
} else if (n instanceof FileAttributeDefinition) {
p = new FileAttributeDefinitionProxy(parent, (FileAttributeDefinition) n);
} else if (n instanceof NumberAttributeDefinition) {
p = new NumberAttributeDefinitionProxy(parent, (NumberAttributeDefinition) n);
} else if (n instanceof RangeAttributeDefinition) {
p = new RangeAttributeDefinitionProxy(parent, (RangeAttributeDefinition) n);
} else if (n instanceof TaxonAttributeDefinition) {
p = new TaxonAttributeDefinitionProxy(parent, (TaxonAttributeDefinition) n);
} else if (n instanceof TextAttributeDefinition) {
p = new TextAttributeDefinitionProxy(parent, (TextAttributeDefinition) n);
} else if (n instanceof TimeAttributeDefinition) {
p = new TimeAttributeDefinitionProxy(parent, (TimeAttributeDefinition) n);
} else {
throw new RuntimeException("AttributeDefinition not supported: " + n.getClass().getSimpleName());
}
} else if (n instanceof EntityDefinition) {
p = new EntityDefinitionProxy(parent, (EntityDefinition) n);
}
if (p != null) {
proxies.add(p);
}
}
}
}
return proxies;
}
use of org.openforis.idm.metamodel.CoordinateAttributeDefinition 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);
}
Aggregations