Search in sources :

Example 11 with Coordinate

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

the class CollectRecordIntegrationTest method addTestValues.

private void addTestValues(Entity cluster, String id) {
    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);
        {
            Entity humanImpact = EntityBuilder.addEntity(plot, "human_impact");
            EntityBuilder.addValue(humanImpact, "type", new Code("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 12 with Coordinate

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

the class ModelDaoIntegrationTest method addTestValues.

private void addTestValues(Entity cluster, String id) {
    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 13 with Coordinate

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

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

the class CoordinateOperations method convertTo.

private Coordinate convertTo(Coordinate coordinate, SpatialReferenceSystem toSrs) {
    SpatialReferenceSystem fromSrs = toSrs(coordinate);
    if (fromSrs.equals(toSrs)) {
        return coordinate;
    } else {
        double[] uiCoordinate = toUiCoordinate(coordinate);
        double[] transformed = CoordinateUtils.transform(fromSrs, uiCoordinate, toSrs);
        return new Coordinate(transformed[0], transformed[1], toSrs.getId());
    }
}
Also used : Coordinate(org.openforis.idm.model.Coordinate) SpatialReferenceSystem(org.openforis.idm.metamodel.SpatialReferenceSystem)

Example 15 with Coordinate

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

the class IDMDistanceFunctionTest method testSampingPointLocation.

// @Test
public void testSampingPointLocation() throws InvalidExpressionException {
    EntityBuilder.addValue(cluster, "id", new Code("10_114"));
    EntityBuilder.addValue(cluster, "cluster_location", new Coordinate(592340d, 9293450d, "EPSG:21036"));
    EntityBuilder.addValue(cluster, "vehicle_location", new Coordinate(592342d, 9293460d, "EPSG:21036"));
    Object distance = evaluateExpression(ExpressionFactory.IDM_PREFIX + ":distance(cluster_location, vehicle_location)");
    Assert.assertEquals(Double.valueOf(10.2010d), round((Double) distance, 6));
}
Also used : Coordinate(org.openforis.idm.model.Coordinate) Code(org.openforis.idm.model.Code)

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