use of org.openforis.collect.metamodel.samplingdesign.SamplingPointGenerationSettings 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);
}
}
use of org.openforis.collect.metamodel.samplingdesign.SamplingPointGenerationSettings 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);
}
}
use of org.openforis.collect.metamodel.samplingdesign.SamplingPointGenerationSettings in project collect by openforis.
the class SurveyCreator method generateSimpleSurvey.
public CollectSurvey generateSimpleSurvey(SimpleSurveyCreationParameters parameters) throws SurveyStoreException, SurveyImportException {
String projectName = parameters.getProjectName();
String internalName = ObjectUtils.defaultIfNull(parameters.getName(), SurveyObjects.adjustInternalName(projectName));
CollectSurvey existingSurvey = surveyManager.get(internalName);
if (existingSurvey != null) {
// TODO move it to validator
throw new IllegalArgumentException(String.format("Survey with name %s already existing", internalName));
}
CollectSurvey survey = createTemporarySimpleSurvey(internalName, parameters.getCodeLists());
survey.setProjectName(survey.getDefaultLanguage(), projectName);
survey.setDescription(survey.getDefaultLanguage(), parameters.getDescription());
UserGroup userGroup = userGroupManager.loadById(parameters.getUserGroupId());
survey.setUserGroup(userGroup);
CeoApplicationOptions ceoApplicationOptions = new CeoApplicationOptions();
ceoApplicationOptions.setBaseMapSource(parameters.getCeoSettings().getBaseMapSource());
ceoApplicationOptions.setImageryYear(parameters.getCeoSettings().getImageryYear());
ceoApplicationOptions.setStackingProfile(parameters.getCeoSettings().getStackingProfile());
SamplingPointGenerationSettings samplingPointGenerationSettings = parameters.getSamplingPointGenerationSettings();
ceoApplicationOptions.setSamplingPointDataConfiguration(samplingPointGenerationSettings);
survey.addApplicationOptions(ceoApplicationOptions);
surveyManager.save(survey);
SamplingPointDataGenerator generator = new SamplingPointDataGenerator(coordinateOperations, survey, parameters.getSamplingPointsByLevel(), samplingPointGenerationSettings);
List<SamplingDesignItem> items = generator.generate();
samplingDesignManager.insert(survey, items, true);
return survey;
}
Aggregations