use of org.openforis.collect.model.CollectSurveyContext 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.CollectSurveyContext in project collect by openforis.
the class SamplingPointDataGeneratorTest method createTestSurvey.
private CollectSurvey createTestSurvey() {
CollectSurvey survey = (CollectSurvey) new CollectSurveyContext().createSurvey();
survey.setId(1);
return survey;
}
use of org.openforis.collect.model.CollectSurveyContext in project collect by openforis.
the class UIOptionsTest method initSurvey.
protected void initSurvey() {
SurveyContext ctx = new CollectSurveyContext(new ExpressionFactory(), new CollectValidator());
survey = (CollectSurvey) ctx.createSurvey();
schema = survey.getSchema();
populateSchema();
initUIOptions();
}
use of org.openforis.collect.model.CollectSurveyContext in project collect by openforis.
the class SamplingPointDataKmlGenerator method createLngLat.
private LngLat createLngLat(Coordinate coord) {
try {
CollectSurveyContext surveyContext = survey.getContext();
CoordinateOperations coordOpts = surveyContext.getCoordinateOperations();
Coordinate wgs84Coord = coordOpts.convertToWgs84(coord);
return new LngLat(wgs84Coord.getX(), wgs84Coord.getY());
} catch (Exception e) {
return null;
}
}
use of org.openforis.collect.model.CollectSurveyContext in project collect by openforis.
the class CollectRelationalTest method loadSurvey.
@BeforeClass
public static void loadSurvey() throws IdmlParseException, FileNotFoundException {
InputStream is = ClassLoader.getSystemResourceAsStream("test.idm.xml");
// InputStream is = new FileInputStream("/home/gino/workspace/of/idm/idm-test/src/main/resources/test.idm.xml");
// InputStream is = new FileInputStream("D:/data/workspace/idm/idm-test/src/main/resources/test.idm.xml");
// InputStream is = new FileInputStream("/home/gino/workspace/faofin/tz/naforma-idm/tanzania-naforma.idm.xml");
CollectSurveyContext ctx = new CollectSurveyContext(new ExpressionFactory(), null);
// DefaultSurveyContext ctx = new DefaultSurveyContext();
CollectSurveyIdmlBinder binder = new CollectSurveyIdmlBinder(ctx);
survey = (CollectSurvey) binder.unmarshal(is);
}
Aggregations