Search in sources :

Example 6 with CoordinateAttribute

use of org.openforis.idm.model.CoordinateAttribute in project collect by openforis.

the class CoordinateColumnProvider method extractValue.

@Override
protected String extractValue(Attribute<?, ?> attr, String fieldName) {
    if (KML_FIELD_NAME.equals(fieldName)) {
        if (attr.isEmpty()) {
            return "";
        } else {
            CoordinateAttribute coordAttr = (CoordinateAttribute) attr;
            String kml = String.format(kmlFormat, coordAttr.getXField().getValue(), coordAttr.getYField().getValue());
            return kml;
        }
    } else {
        return super.extractValue(attr, fieldName);
    }
}
Also used : CoordinateAttribute(org.openforis.idm.model.CoordinateAttribute)

Example 7 with CoordinateAttribute

use of org.openforis.idm.model.CoordinateAttribute in project collect by openforis.

the class CoordinateAttributeMapper method setFields.

@Override
void setFields(Node<?> node, InsertSetStep<?> insert) {
    CoordinateAttribute c = (CoordinateAttribute) node;
    Coordinate value = c.getValue();
    if (value != null) {
        insert.set(DATA.NUMBER1, toNumeric(value.getX()));
        insert.set(DATA.NUMBER2, toNumeric(value.getY()));
        // insert.set(DATA.NUMBER3, toNumeric(value.getZ()));
        insert.set(DATA.TEXT1, value.getSrsId());
    }
}
Also used : Coordinate(org.openforis.idm.model.Coordinate) CoordinateAttribute(org.openforis.idm.model.CoordinateAttribute)

Example 8 with CoordinateAttribute

use of org.openforis.idm.model.CoordinateAttribute in project collect by openforis.

the class DistanceCheckTest method testValidMaxDistance.

@Test
public void testValidMaxDistance() {
    String coordStr = "SRID=EPSG:21035;POINT(805750 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()));
}
Also used : ValidationResults(org.openforis.idm.metamodel.validation.ValidationResults) Coordinate(org.openforis.idm.model.Coordinate) CoordinateAttribute(org.openforis.idm.model.CoordinateAttribute) Code(org.openforis.idm.model.Code) Test(org.junit.Test)

Example 9 with CoordinateAttribute

use of org.openforis.idm.model.CoordinateAttribute in project collect by openforis.

the class GeoDataController method loadCoordinateValues.

@RequestMapping(value = "survey/{surveyId}/data/coordinatevalues.json", method = GET)
@ResponseBody
public List<CoordinateAttributePoint> loadCoordinateValues(@PathVariable int surveyId, @RequestParam int coordinateAttributeId, @RequestParam String srsId, @RequestParam int recordOffset, @RequestParam int maxNumberOfRecords) throws Exception {
    final List<CoordinateAttributePoint> result = new ArrayList<CoordinateAttributePoint>();
    CollectSurvey survey = surveyManager.loadSurvey(surveyId);
    extractAllRecordCoordinates(survey, recordOffset, maxNumberOfRecords, coordinateAttributeId, srsId, new CoordinateProcessor() {

        public void process(CollectRecord record, CoordinateAttribute coordAttr, Coordinate coordinate) {
            CoordinateAttributePoint point = new CoordinateAttributePoint(coordAttr, coordinate);
            result.add(point);
        }
    });
    return result;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) Coordinate(org.openforis.idm.model.Coordinate) CoordinateAttribute(org.openforis.idm.model.CoordinateAttribute) ArrayList(java.util.ArrayList) CollectSurvey(org.openforis.collect.model.CollectSurvey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

CoordinateAttribute (org.openforis.idm.model.CoordinateAttribute)9 Coordinate (org.openforis.idm.model.Coordinate)7 Test (org.junit.Test)5 Code (org.openforis.idm.model.Code)5 ValidationResults (org.openforis.idm.metamodel.validation.ValidationResults)3 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)2 DistanceCheck (org.openforis.idm.metamodel.validation.DistanceCheck)2 ArrayList (java.util.ArrayList)1 ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 NodeChangeSet (org.openforis.collect.model.NodeChangeSet)1 SpatialReferenceSystem (org.openforis.idm.metamodel.SpatialReferenceSystem)1 Survey (org.openforis.idm.metamodel.Survey)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1