Search in sources :

Example 31 with Coordinate

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

the class DataMarshallerIntegrationTest method createTestRecord.

private CollectRecord createTestRecord(CollectSurvey survey) {
    RecordBuilder recordBuilder = record(attribute("id", "123_456"), attribute("gps_realtime", "true"), attribute("region", "001"), attribute("district", "XXX"), attribute("crew_no", 10), attribute("map_sheet", "value 1"), attribute("map_sheet", "value 2"), attribute("vehicle_location", new Coordinate(432423423d, 4324324d, "srs")), attribute("gps_model", "TomTom 1.232"), attribute("remarks", "Remarks with UTF-8 character: Í"), entity("time_study", attribute("date", new Date(2011, 2, 14)), attribute("start_time", new Time(8, 15)), attribute("end_time", new Time(15, 29))), entity("time_study", attribute("date", new Date(2011, 2, 15)), attribute("start_time", new Time(8, 32)), attribute("end_time", new Time(11, 20))), entity("plot", attribute("no", new Code("1")), entity("tree", attribute("tree_no", 1), attribute("dbh", 54.2), attribute("total_height", 2.0), attribute("bole_height", (Double) null)), entity("tree", attribute("tree_no", 2), attribute("dbh", 82.8), attribute("total_height", 3.0))), entity("plot", attribute("no", new Code("2")), entity("tree", attribute("tree_no", 1), attribute("dbh", 34.2), attribute("total_height", 2.0)), entity("tree", attribute("tree_no", 2), attribute("dbh", 85.8), attribute("total_height", 4.0))));
    CollectRecord record = recordBuilder.build(survey, "cluster", "2.0");
    User user = userManager.loadByUserName("admin");
    record.setCreatedBy(user);
    record.setModifiedBy(user);
    record.setCreationDate(new GregorianCalendar(2011, 11, 31, 23, 59).getTime());
    record.setModifiedDate(new GregorianCalendar(2012, 2, 3, 9, 30).getTime());
    record.setStep(Step.ENTRY);
    record.setState(State.REJECTED);
    record.updateSummaryFields();
    RecordUpdater recordUpdater = new RecordUpdater();
    recordUpdater.initializeRecord(record);
    Entity cluster = record.getRootEntity();
    recordUpdater.confirmError((Attribute<?, ?>) record.findNodeByPath("/cluster/district"));
    recordUpdater.approveMissingValue(cluster, "accessibility");
    NumberAttribute<?, ?> boleHeight = (NumberAttribute<?, ?>) record.findNodeByPath("/cluster/plot[1]/tree[1]/bole_height");
    recordUpdater.updateAttribute(boleHeight, FieldSymbol.BLANK_ON_FORM);
    recordUpdater.updateRemarks(boleHeight.getNumberField(), "No value specified");
    return record;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) Entity(org.openforis.idm.model.Entity) User(org.openforis.collect.model.User) RecordBuilder(org.openforis.idm.testfixture.RecordBuilder) GregorianCalendar(java.util.GregorianCalendar) Time(org.openforis.idm.model.Time) Code(org.openforis.idm.model.Code) Date(org.openforis.idm.model.Date) Coordinate(org.openforis.idm.model.Coordinate) NumberAttribute(org.openforis.idm.model.NumberAttribute) RecordUpdater(org.openforis.collect.model.RecordUpdater)

Example 32 with Coordinate

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

the class ModelSerializationTest method createTestRecord.

private CollectRecord createTestRecord(CollectSurvey survey) {
    RecordBuilder recordBuilder = record(attribute("id", new Code("123_456")), attribute("gps_realtime", "true"), attribute("region", "001"), attribute("district", "002"), attribute("crew_no", 10), attribute("map_sheet", "value 1"), attribute("map_sheet", "value 2"), attribute("vehicle_location", new Coordinate(432423423d, 4324324d, "srs")), attribute("gps_model", "TomTom 1.232"), entity("time_study", attribute("date", new Date(2011, 2, 14)), attribute("start_time", new Time(8, 15)), attribute("end_time", new Time(15, 29))), entity("time_study", attribute("date", new Date(2011, 2, 15)), attribute("start_time", new Time(8, 32)), attribute("end_time", new Time(11, 20))), entity("plot", attribute("no", new Code("1")), entity("tree", attribute("tree_no", 1), attribute("dbh", 54.2), attribute("total_height", 2.0), attribute("bole_height", (Double) null)), entity("tree", attribute("tree_no", 2), attribute("dbh", 82.8), attribute("total_height", 3.0))), entity("plot", attribute("no", new Code("2")), entity("tree", attribute("tree_no", 1), attribute("dbh", 34.2), attribute("total_height", 2.0)), entity("tree", attribute("tree_no", 2), attribute("dbh", 85.8), attribute("total_height", 4.0))));
    CollectRecord record = recordBuilder.build(survey, "cluster", "2.0");
    record.setCreationDate(new GregorianCalendar(2011, 11, 31, 23, 59).getTime());
    // record.setCreatedBy("ModelDaoIntegrationTest");
    record.setStep(Step.ENTRY);
    record.updateSummaryFields();
    updater.initializeRecord(record);
    Entity cluster = record.getRootEntity();
    updater.confirmError((Attribute<?, ?>) record.findNodeByPath("/cluster/district"));
    updater.approveMissingValue(cluster, "accessibility");
    NumberAttribute<?, ?> boleHeight = (NumberAttribute<?, ?>) record.findNodeByPath("/cluster/plot[1]/tree[1]/bole_height");
    updater.updateAttribute(boleHeight, FieldSymbol.BLANK_ON_FORM);
    updater.updateRemarks(boleHeight.getNumberField(), "No value specified");
    return record;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) Entity(org.openforis.idm.model.Entity) Coordinate(org.openforis.idm.model.Coordinate) RecordBuilder(org.openforis.idm.testfixture.RecordBuilder) GregorianCalendar(java.util.GregorianCalendar) NumberAttribute(org.openforis.idm.model.NumberAttribute) Time(org.openforis.idm.model.Time) Code(org.openforis.idm.model.Code) Date(org.openforis.idm.model.Date)

Example 33 with Coordinate

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

the class CollectRelationalTest method addTestValues.

private static void addTestValues(Entity cluster, String id) {
    // cluster.setId(100);
    EntityBuilder.addValue(cluster, "id", new Code(id));
    EntityBuilder.addValue(cluster, "gps_realtime", Boolean.TRUE);
    EntityBuilder.addValue(cluster, "region", new Code("001"));
    EntityBuilder.addValue(cluster, "district", new Code("002"));
    EntityBuilder.addValue(cluster, "crew_no", 10);
    EntityBuilder.addValue(cluster, "map_sheet", "value 1");
    EntityBuilder.addValue(cluster, "map_sheet", "value 2");
    EntityBuilder.addValue(cluster, "vehicle_location", new Coordinate((double) 432423423l, (double) 4324324l, "srs"));
    EntityBuilder.addValue(cluster, "gps_model", "TomTom 1.232");
    {
        Entity ts = EntityBuilder.addEntity(cluster, "time_study");
        EntityBuilder.addValue(ts, "date", new Date(2011, 2, 14));
        EntityBuilder.addValue(ts, "start_time", new Time(8, 15));
        EntityBuilder.addValue(ts, "end_time", new Time(15, 29));
    }
    {
        Entity ts = EntityBuilder.addEntity(cluster, "time_study");
        EntityBuilder.addValue(ts, "date", new Date(2011, 2, 15));
        EntityBuilder.addValue(ts, "start_time", new Time(8, 32));
        EntityBuilder.addValue(ts, "end_time", new Time(11, 20));
    }
    {
        Entity plot = EntityBuilder.addEntity(cluster, "plot");
        EntityBuilder.addValue(plot, "no", new Code("1"));
        Entity tree1 = EntityBuilder.addEntity(plot, "tree");
        EntityBuilder.addValue(tree1, "tree_no", 1);
        EntityBuilder.addValue(tree1, "dbh", 54.2);
        EntityBuilder.addValue(tree1, "total_height", 2.0);
        // EntityBuilder.addValue(tree1, "bole_height", (Double) null).setMetadata(new CollectAttributeMetadata('*',null,"No value specified"));
        RealAttribute boleHeight = EntityBuilder.addValue(tree1, "bole_height", (Double) null);
        boleHeight.getField(0).setSymbol('*');
        boleHeight.getField(0).setRemarks("No value specified");
        Entity tree2 = EntityBuilder.addEntity(plot, "tree");
        EntityBuilder.addValue(tree2, "tree_no", 2);
        EntityBuilder.addValue(tree2, "dbh", 82.8);
        EntityBuilder.addValue(tree2, "total_height", 3.0);
    }
    {
        Entity plot = EntityBuilder.addEntity(cluster, "plot");
        EntityBuilder.addValue(plot, "no", new Code("2"));
        Entity tree1 = EntityBuilder.addEntity(plot, "tree");
        EntityBuilder.addValue(tree1, "tree_no", 1);
        EntityBuilder.addValue(tree1, "dbh", 34.2);
        EntityBuilder.addValue(tree1, "total_height", 2.0);
        Entity tree2 = EntityBuilder.addEntity(plot, "tree");
        EntityBuilder.addValue(tree2, "tree_no", 2);
        EntityBuilder.addValue(tree2, "dbh", 85.8);
        EntityBuilder.addValue(tree2, "total_height", 4.0);
    }
}
Also used : Entity(org.openforis.idm.model.Entity) Coordinate(org.openforis.idm.model.Coordinate) RealAttribute(org.openforis.idm.model.RealAttribute) Time(org.openforis.idm.model.Time) Code(org.openforis.idm.model.Code) Date(org.openforis.idm.model.Date)

Example 34 with Coordinate

use of org.openforis.idm.model.Coordinate 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 35 with Coordinate

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

the class SamplingPointsController method createLngLatAlt.

private LngLatAlt createLngLatAlt(CoordinateOperations coordOpts, Coordinate coord) {
    try {
        Coordinate wgs84Coord = coordOpts.convertToWgs84(coord);
        LngLatAlt lngLatAlt = new LngLatAlt(wgs84Coord.getX(), wgs84Coord.getY());
        return lngLatAlt;
    } catch (Exception e) {
        return null;
    }
}
Also used : Coordinate(org.openforis.idm.model.Coordinate) LngLatAlt(org.geojson.LngLatAlt) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Coordinate (org.openforis.idm.model.Coordinate)46 Code (org.openforis.idm.model.Code)14 Test (org.junit.Test)8 Date (org.openforis.idm.model.Date)8 Time (org.openforis.idm.model.Time)8 ArrayList (java.util.ArrayList)7 SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)7 CoordinateAttribute (org.openforis.idm.model.CoordinateAttribute)7 Entity (org.openforis.idm.model.Entity)7 CollectRecord (org.openforis.collect.model.CollectRecord)5 GregorianCalendar (java.util.GregorianCalendar)4 SamplingPointLevelGenerationSettings (org.openforis.collect.metamodel.samplingdesign.SamplingPointLevelGenerationSettings)4 CollectSurvey (org.openforis.collect.model.CollectSurvey)4 CoordinateOperations (org.openforis.idm.geospatial.CoordinateOperations)4 RealAttribute (org.openforis.idm.model.RealAttribute)4 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)3 ValidationResults (org.openforis.idm.metamodel.validation.ValidationResults)3 NumberAttribute (org.openforis.idm.model.NumberAttribute)3 RecordBuilder (org.openforis.idm.testfixture.RecordBuilder)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2