Search in sources :

Example 76 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class SamplingPointDataGeneratorTest method griddedPlotsGenerationTest.

@Test
public void griddedPlotsGenerationTest() {
    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();
    // printLatLonPoints(items);
    assertTrue(items.size() <= numPlots + numPlots * samplesPerPlot);
    List<SamplingDesignItem> plotItems = getSamplingItemsInLevel(items, 1);
    assertTrue(plotItems.size() <= numPlots);
    for (SamplingDesignItem plotItem : plotItems) {
        assertPointInSquare(plotItem, topLeftCoordinate, bottomRightCoordinate);
    }
}
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) Test(org.junit.Test)

Example 77 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey 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 78 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class SamplingPointDataGeneratorTest method createTestSurvey.

private CollectSurvey createTestSurvey() {
    CollectSurvey survey = (CollectSurvey) new CollectSurveyContext().createSurvey();
    survey.setId(1);
    return survey;
}
Also used : CollectSurveyContext(org.openforis.collect.model.CollectSurveyContext) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 79 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class BackupService method getBackup.

private BackupProcess getBackup(String rootEntityName) throws Exception {
    SessionState sessionState = sessionManager.getSessionState();
    CollectSurvey survey = sessionState.getActiveSurvey();
    Integer surveyId = survey.getId();
    Map<String, BackupProcess> backupsPerSurvey = backups.get(surveyId);
    if (backupsPerSurvey == null) {
        backupsPerSurvey = new HashMap<String, BackupProcess>();
        backups.put(surveyId, backupsPerSurvey);
    }
    BackupProcess backup = backupsPerSurvey.get(rootEntityName);
    if (backup == null) {
        int[] stepNumbers = { 1, 2, 3 };
        backup = new BackupProcess(surveyManager, recordManager, dataMarshaller, backupDirectory, survey, rootEntityName, stepNumbers);
        backupsPerSurvey.put(rootEntityName, backup);
    }
    return backup;
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) BackupProcess(org.openforis.collect.remoting.service.backup.BackupProcess) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 80 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class AbstractSurveyObjectEditFormController method loadOrCreateItem.

@Override
protected T loadOrCreateItem(F form) {
    T item;
    if (form.getId() == null) {
        CollectSurvey survey = getActiveSurvey();
        item = createItemInstance(survey);
    } else {
        item = loadItem(form.getId());
    }
    return item;
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey)

Aggregations

CollectSurvey (org.openforis.collect.model.CollectSurvey)329 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)53 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)40 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)38 CollectRecord (org.openforis.collect.model.CollectRecord)30 RecordFilter (org.openforis.collect.model.RecordFilter)27 Transactional (org.springframework.transaction.annotation.Transactional)26 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)25 ArrayList (java.util.ArrayList)23 File (java.io.File)21 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)21 Secured (org.springframework.security.access.annotation.Secured)20 User (org.openforis.collect.model.User)19 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)19 SessionState (org.openforis.collect.web.session.SessionState)18 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)17 Test (org.junit.Test)16 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)15 CodeList (org.openforis.idm.metamodel.CodeList)15 Schema (org.openforis.idm.metamodel.Schema)15