Search in sources :

Example 1 with SamplingDesignSummaries

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;
}
Also used : ArrayList(java.util.ArrayList) SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem)

Example 2 with SamplingDesignSummaries

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;
}
Also used : CoordinateOperations(org.openforis.idm.geospatial.CoordinateOperations) Coordinate(org.openforis.idm.model.Coordinate) CollectSurveyContext(org.openforis.collect.model.CollectSurveyContext) SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) CollectSurvey(org.openforis.collect.model.CollectSurvey) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem) LngLatAlt(org.geojson.LngLatAlt) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with SamplingDesignSummaries

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"));
}
Also used : SamplingDesignImportProcess(org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportProcess) SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem) SamplingDesignImportStatus(org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 4 with SamplingDesignSummaries

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());
    }
}
Also used : SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) CollectSurvey(org.openforis.collect.model.CollectSurvey) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 5 with SamplingDesignSummaries

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"));
}
Also used : SamplingDesignImportProcess(org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportProcess) SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem) SamplingDesignImportStatus(org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Aggregations

SamplingDesignSummaries (org.openforis.collect.model.SamplingDesignSummaries)9 SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)8 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)3 CollectSurvey (org.openforis.collect.model.CollectSurvey)3 SamplingDesignImportProcess (org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportProcess)2 SamplingDesignImportStatus (org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus)2 CsvWriter (org.openforis.commons.io.csv.CsvWriter)2 LngLatAlt (org.geojson.LngLatAlt)1 CollectSurveyContext (org.openforis.collect.model.CollectSurveyContext)1 SamplingDesignSummariesProxy (org.openforis.collect.model.proxy.SamplingDesignSummariesProxy)1 CoordinateOperations (org.openforis.idm.geospatial.CoordinateOperations)1 ReferenceDataDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition)1 Coordinate (org.openforis.idm.model.Coordinate)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1