use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.
the class SamplingPointsController method loadSamplingDesignItems.
private List<SamplingDesignItem> loadSamplingDesignItems(CollectSurvey survey) {
SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId());
List<SamplingDesignItem> samplingDesignItems = samplingDesignSummaries.getRecords();
List<SamplingDesignItem> result = new ArrayList<SamplingDesignItem>();
for (SamplingDesignItem item : samplingDesignItems) {
result.add(item);
}
return result;
}
use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.
the class SamplingPointsController method loadSamplingPointBounds.
@RequestMapping(value = "survey/{surveyId}/sampling_point_bounds.json", method = GET)
@ResponseBody
public Bounds loadSamplingPointBounds(@PathVariable int surveyId) {
CollectSurvey survey = surveyManager.loadSurvey(surveyId);
CollectSurveyContext surveyContext = survey.getContext();
CoordinateOperations coordinateOperations = surveyContext.getCoordinateOperations();
SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId());
List<SamplingDesignItem> samplingDesignItems = samplingDesignSummaries.getRecords();
Bounds bounds = new Bounds();
for (SamplingDesignItem item : samplingDesignItems) {
Coordinate coordinate = new Coordinate(item.getX(), item.getY(), item.getSrsId());
LngLatAlt lngLatAlt = createLngLatAlt(coordinateOperations, coordinate);
if (lngLatAlt != null) {
if (bounds.topLeft == null) {
bounds.topLeft = bounds.topRight = bounds.bottomLeft = bounds.bottomRight = lngLatAlt;
} else {
if (lngLatAlt.getLatitude() < bounds.topLeft.getLatitude() && lngLatAlt.getLongitude() < bounds.topLeft.getLongitude()) {
bounds.topLeft = lngLatAlt;
} else if (lngLatAlt.getLatitude() < bounds.topRight.getLatitude() && lngLatAlt.getLongitude() > bounds.topRight.getLongitude()) {
bounds.topRight = lngLatAlt;
} else if (lngLatAlt.getLatitude() > bounds.bottomRight.getLatitude() && lngLatAlt.getLongitude() > bounds.bottomRight.getLongitude()) {
bounds.bottomRight = lngLatAlt;
} else if (lngLatAlt.getLatitude() > bounds.bottomLeft.getLatitude() && lngLatAlt.getLongitude() > bounds.bottomLeft.getLongitude()) {
bounds.bottomLeft = lngLatAlt;
}
}
}
}
return bounds;
}
use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.
the class SamplingDesignImportProcessIntegrationTest method testImport.
@Test
public void testImport() throws Exception {
SamplingDesignImportProcess process = importCSVFile(VALID_TEST_CSV);
SamplingDesignImportStatus status = process.getStatus();
assertTrue(status.isComplete());
assertTrue(status.getSkippedRows().isEmpty());
assertEquals(27, status.getProcessed());
SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId(), 0, 30);
assertNotNull(samplingDesignSummaries);
assertEquals(26, samplingDesignSummaries.getTotalCount());
List<SamplingDesignItem> items = samplingDesignSummaries.getRecords();
assertNotNull(findItem(items, -10000d, 100000d, "1_01", "1"));
assertNotNull(findItem(items, 200000d, -2000000d, "1_02", "1"));
assertNotNull(findItem(items, 806090d, 9320050d, "10_114", "7"));
assertNotNull(findItem(items, 805680d, 9305020d, "10_117", "6"));
}
use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.
the class SurveyManagerIntegrationTest method duplicateSurveySamplingDesignForEditTest.
@Test
public void duplicateSurveySamplingDesignForEditTest() {
insertTestSamplingDesign();
CollectSurvey surveyWork = surveyManager.createTemporarySurveyFromPublished(survey.getUri(), adminUser);
SamplingDesignSummaries summaries = samplingDesignManager.loadBySurvey(surveyWork.getId());
List<SamplingDesignItem> records = summaries.getRecords();
assertEquals(3, records.size());
{
SamplingDesignItem item = records.get(0);
assertEquals(Arrays.asList("7_81"), item.getLevelCodes());
assertEquals("EPSG:21035", item.getSrsId());
assertEquals(Double.valueOf(792200d), item.getX());
assertEquals(Double.valueOf(9484420d), item.getY());
}
{
SamplingDesignItem item = records.get(1);
assertEquals(Arrays.asList("7_81", "2"), item.getLevelCodes());
assertEquals("EPSG:21035", item.getSrsId());
assertEquals(Double.valueOf(792200d), item.getX());
assertEquals(Double.valueOf(9484420d), item.getY());
}
{
SamplingDesignItem item = records.get(2);
assertEquals(Arrays.asList("7_81", "3"), item.getLevelCodes());
assertEquals("EPSG:21035", item.getSrsId());
assertEquals(Double.valueOf(792200d), item.getX());
assertEquals(Double.valueOf(9484670d), item.getY());
}
}
use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.
the class SamplingDesignImportProcessIntegrationTest method testFlatImport.
@Test
public void testFlatImport() throws Exception {
SamplingDesignImportProcess process = importCSVFile(VALID_FLAT_TEST_CSV);
SamplingDesignImportStatus status = process.getStatus();
assertTrue(status.isComplete());
assertTrue(status.getSkippedRows().isEmpty());
SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId(), 0, 30);
assertNotNull(samplingDesignSummaries);
assertEquals(6, samplingDesignSummaries.getTotalCount());
List<SamplingDesignItem> items = samplingDesignSummaries.getRecords();
{
SamplingDesignItem item = findItem(items, -10000d, 100000d, "1_01");
assertNotNull(item);
assertEquals(Arrays.asList("001", "002"), item.getInfoAttributes().subList(0, 2));
}
assertNotNull(findItem(items, 200000d, -2000000d, "1_02"));
assertNotNull(findItem(items, 806340d, 9320050d, "10_114"));
assertNotNull(findItem(items, 806680d, 9305020d, "10_117"));
assertNotNull(findItem(items, 80.1234d, -6.908d, "10_115"));
}
Aggregations