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;
}
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();
}
}
}
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;
}
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"));
}
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);
}
}
Aggregations