Search in sources :

Example 16 with SamplingDesignItem

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

the class SamplingPointDataKmlGenerator method generate.

public void generate() {
    Kml kml = KmlFactory.createKml();
    Document doc = kml.createAndSetDocument();
    List<SamplingDesignItem> samplingDesignItems = loadSamplingDesignItems();
    for (SamplingDesignItem item : samplingDesignItems) {
        Coordinate coordinate = new Coordinate(item.getX(), item.getY(), item.getSrsId());
        LngLat lngLatAlt = createLngLat(coordinate);
        doc.createAndAddPlacemark().withName(Strings.joinNotBlank(item.getLevelCodes(), "|")).withOpen(true).createAndSetPoint().addToCoordinates(lngLatAlt.getLongitude(), lngLatAlt.getLatitude());
    }
    this.kml = kml;
}
Also used : LngLat(org.openforis.collect.model.LngLat) Coordinate(org.openforis.idm.model.Coordinate) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Document(de.micromata.opengis.kml.v_2_2_0.Document) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem)

Example 17 with SamplingDesignItem

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

the class SamplingDesignDao method visitItems.

public void visitItems(int surveyId, Integer upToLevel, Visitor<SamplingDesignItem> visitor) {
    SamplingDesignDSLContext dsl = dsl();
    SelectQuery<Record> q = createSelectItemsQuery(dsl, surveyId, upToLevel);
    Cursor<Record> cursor = null;
    try {
        cursor = q.fetchLazy();
        while (cursor.hasNext()) {
            Record record = cursor.fetchOne();
            SamplingDesignItem s = dsl.fromRecord(record);
            visitor.visit(s);
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
Also used : OfcSamplingDesignRecord(org.openforis.collect.persistence.jooq.tables.records.OfcSamplingDesignRecord) Record(org.jooq.Record) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem)

Example 18 with SamplingDesignItem

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

the class SamplingDesignItemProxy method fromList.

public static List<SamplingDesignItemProxy> fromList(List<SamplingDesignItem> list) {
    List<SamplingDesignItemProxy> result = new ArrayList<SamplingDesignItemProxy>();
    if (list != null) {
        for (SamplingDesignItem item : list) {
            SamplingDesignItemProxy proxy = new SamplingDesignItemProxy(item);
            result.add(proxy);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem)

Example 19 with SamplingDesignItem

use of org.openforis.collect.model.SamplingDesignItem 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)

Example 20 with SamplingDesignItem

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

the class SamplingPointsController method convertTo.

private SamplingDesignItem convertTo(SamplingDesignItem item, String targetSrsId) {
    try {
        SamplingDesignItem newItem = new SamplingDesignItem();
        BeanUtils.copyProperties(newItem, item);
        Coordinate newCoordinate = coordinateOperations.convertTo(item.getCoordinate(), targetSrsId);
        newItem.setCoordinate(newCoordinate);
        return newItem;
    } catch (IllegalAccessException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}
Also used : Coordinate(org.openforis.idm.model.Coordinate) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)26 ArrayList (java.util.ArrayList)9 SamplingDesignSummaries (org.openforis.collect.model.SamplingDesignSummaries)8 Coordinate (org.openforis.idm.model.Coordinate)7 CollectSurvey (org.openforis.collect.model.CollectSurvey)6 Test (org.junit.Test)5 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)3 SamplingPointDataGenerator (org.openforis.collect.io.metadata.samplingpointdata.SamplingPointDataGenerator)3 SamplingPointGenerationSettings (org.openforis.collect.metamodel.samplingdesign.SamplingPointGenerationSettings)3 SamplingDesignImportProcess (org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportProcess)2 SamplingDesignImportStatus (org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus)2 SamplingPointLevelGenerationSettings (org.openforis.collect.metamodel.samplingdesign.SamplingPointLevelGenerationSettings)2 OfcSamplingDesignRecord (org.openforis.collect.persistence.jooq.tables.records.OfcSamplingDesignRecord)2 CsvWriter (org.openforis.commons.io.csv.CsvWriter)2 CoordinateOperations (org.openforis.idm.geospatial.CoordinateOperations)2 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)2 ReferenceDataSchema (org.openforis.idm.metamodel.ReferenceDataSchema)2 SamplingPointDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition)2 Document (de.micromata.opengis.kml.v_2_2_0.Document)1 Kml (de.micromata.opengis.kml.v_2_2_0.Kml)1