Search in sources :

Example 1 with CoordinateAttributeDefinition

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);
}
Also used : CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) DistanceCheck(org.openforis.idm.metamodel.validation.DistanceCheck) Coordinate(org.openforis.idm.model.Coordinate) CoordinateAttribute(org.openforis.idm.model.CoordinateAttribute) Code(org.openforis.idm.model.Code) Test(org.junit.Test)

Example 2 with CoordinateAttributeDefinition

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);
}
Also used : CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) DistanceCheck(org.openforis.idm.metamodel.validation.DistanceCheck) Coordinate(org.openforis.idm.model.Coordinate) CoordinateAttribute(org.openforis.idm.model.CoordinateAttribute) Code(org.openforis.idm.model.Code) Test(org.junit.Test)

Example 3 with CoordinateAttributeDefinition

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);
}
Also used : CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) Coordinate(org.openforis.idm.model.Coordinate) SpatialReferenceSystem(org.openforis.idm.metamodel.SpatialReferenceSystem)

Example 4 with CoordinateAttributeDefinition

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;
}
Also used : TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) NumberAttributeDefinition(org.openforis.idm.metamodel.NumberAttributeDefinition) TimeAttributeDefinition(org.openforis.idm.metamodel.TimeAttributeDefinition) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) RangeAttributeDefinition(org.openforis.idm.metamodel.RangeAttributeDefinition) DateAttributeDefinition(org.openforis.idm.metamodel.DateAttributeDefinition) TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition) DateAttributeDefinition(org.openforis.idm.metamodel.DateAttributeDefinition) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition) FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition) TimeAttributeDefinition(org.openforis.idm.metamodel.TimeAttributeDefinition) NumberAttributeDefinition(org.openforis.idm.metamodel.NumberAttributeDefinition) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) RangeAttributeDefinition(org.openforis.idm.metamodel.RangeAttributeDefinition)

Example 5 with CoordinateAttributeDefinition

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);
}
Also used : CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) CoordinateOperations(org.openforis.idm.geospatial.CoordinateOperations) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordCoordinatesKmlGeneratorJob(org.openforis.collect.model.RecordCoordinatesKmlGeneratorJob) RecordFilter(org.openforis.collect.model.RecordFilter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)8 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)4 CollectSurvey (org.openforis.collect.model.CollectSurvey)3 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)3 Coordinate (org.openforis.idm.model.Coordinate)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 CodeTable (org.openforis.collect.relational.model.CodeTable)2 DataTable (org.openforis.collect.relational.model.DataTable)2 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)2 TaxonAttributeDefinition (org.openforis.idm.metamodel.TaxonAttributeDefinition)2 TextAttributeDefinition (org.openforis.idm.metamodel.TextAttributeDefinition)2 TimeAttributeDefinition (org.openforis.idm.metamodel.TimeAttributeDefinition)2 DistanceCheck (org.openforis.idm.metamodel.validation.DistanceCheck)2 Code (org.openforis.idm.model.Code)2 CoordinateAttribute (org.openforis.idm.model.CoordinateAttribute)2 List (java.util.List)1 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)1 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)1 CoordinateAttributeFieldsOrder (org.openforis.collect.metamodel.ui.UIOptions.CoordinateAttributeFieldsOrder)1