Search in sources :

Example 6 with Coordinate

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

the class SamplingPointDataGeneratorTest method randomSamplingPointsGenerationTest.

@Test
public void randomSamplingPointsGenerationTest() {
    Coordinate topLeftCoordinate = new Coordinate(12.369192d, 41.987927d, LAT_LON_SRS_ID);
    Coordinate topRightCoordinate = new Coordinate(12.621191d, 41.987927d, LAT_LON_SRS_ID);
    Coordinate bottomLeftCoordinate = new Coordinate(12.369192d, 41.802904d, LAT_LON_SRS_ID);
    Coordinate bottomRightCoordinate = new Coordinate(12.621191d, 41.802904d, LAT_LON_SRS_ID);
    int numPlots = 25;
    int samplesPerPlot = 10;
    int plotWidth = 1000;
    SamplingPointLevelGenerationSettings plotPointsConfig = new SamplingPointLevelGenerationSettings(numPlots, Shape.CIRCLE, Distribution.GRIDDED, 5000, plotWidth);
    SamplingPointLevelGenerationSettings samplePointsConfig = new SamplingPointLevelGenerationSettings(samplesPerPlot, Shape.CIRCLE, Distribution.RANDOM, 20, 10);
    CollectSurvey survey = createTestSurvey();
    SamplingPointGenerationSettings conf = new SamplingPointGenerationSettings();
    conf.setAoiBoundary(Arrays.asList(topLeftCoordinate, topRightCoordinate, bottomLeftCoordinate, bottomRightCoordinate));
    conf.setLevelsSettings(Arrays.asList(plotPointsConfig, samplePointsConfig));
    SamplingPointDataGenerator generator = new SamplingPointDataGenerator(coordinateOperations, survey, null, conf);
    List<SamplingDesignItem> items = generator.generate();
    List<SamplingDesignItem> plotItems = getSamplingItemsInLevel(items, 1);
    List<SamplingDesignItem> samplingPointItems = getSamplingItemsInLevel(items, 2);
    assertEquals(plotItems.size() * samplesPerPlot, samplingPointItems.size());
    for (final SamplingDesignItem samplingPointItem : samplingPointItems) {
        SamplingDesignItem plotItem = (SamplingDesignItem) CollectionUtils.find(items, new Predicate() {

            public boolean evaluate(Object object) {
                return Arrays.asList(samplingPointItem.getLevelCode(1)).equals(((SamplingDesignItem) object).getLevelCodes());
            }
        });
        assertNotNull(plotItem);
        assertPointInCircle(samplingPointItem, new Coordinate(plotItem.getX(), plotItem.getY(), LAT_LON_SRS_ID), plotWidth / 2);
    }
}
Also used : SamplingPointGenerationSettings(org.openforis.collect.metamodel.samplingdesign.SamplingPointGenerationSettings) Coordinate(org.openforis.idm.model.Coordinate) SamplingPointDataGenerator(org.openforis.collect.io.metadata.samplingpointdata.SamplingPointDataGenerator) CollectSurvey(org.openforis.collect.model.CollectSurvey) SamplingPointLevelGenerationSettings(org.openforis.collect.metamodel.samplingdesign.SamplingPointLevelGenerationSettings) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem) Predicate(org.apache.commons.collections.Predicate) Test(org.junit.Test)

Example 7 with Coordinate

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

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

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

the class DistanceCheckTest method testWarnMaxDistance.

@Test
public void testWarnMaxDistance() {
    String coordStr = "SRID=EPSG:21035;POINT(885750 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()));
    Assert.assertTrue(containsDistanceCheck(results.getWarnings()));
}
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 10 with Coordinate

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

the class DistanceCheckTest method testErrorMaxDistance.

@Test
public void testErrorMaxDistance() {
    String coordStr = "SRID=EPSG:21035;POINT(915750 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.assertTrue(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)

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