use of org.openforis.idm.geospatial.CoordinateOperations in project collect by openforis.
the class SRSFormValidator method validateWKT.
private boolean validateWKT(ValidationContext ctx) {
String wkt = (String) getValue(ctx, WKT_FIELD);
CollectSurvey survey = getSurvey(ctx);
SurveyContext context = survey.getContext();
CoordinateOperations coordinateOperations = context.getCoordinateOperations();
try {
coordinateOperations.validateWKT(wkt);
return true;
} catch (Exception e) {
String message = Labels.getLabel("survey.srs.validation.error.invalid_wkt", new String[] { e.getMessage() });
addInvalidMessage(ctx, WKT_FIELD, message);
return false;
}
}
use of org.openforis.idm.geospatial.CoordinateOperations in project collect by openforis.
the class SamplingPointsController method loadSamplingPointDataFeatures.
private FeatureCollection loadSamplingPointDataFeatures(CollectSurvey survey) {
FeatureCollection featureCollection = new FeatureCollection();
Feature feature = new Feature();
feature.setProperty("letter", "o");
feature.setProperty("color", "blue");
feature.setProperty("rank", "15");
MultiPoint multiPoint = new MultiPoint();
CoordinateOperations coordinateOperations = getCoordinateOperations(survey);
List<SamplingDesignItem> samplingDesignItems = loadSamplingDesignItems(survey);
for (SamplingDesignItem item : samplingDesignItems) {
Coordinate coordinate = new Coordinate(item.getX(), item.getY(), item.getSrsId());
multiPoint.add(createLngLatAlt(coordinateOperations, coordinate));
}
feature.setGeometry(multiPoint);
featureCollection.add(feature);
return featureCollection;
}
use of org.openforis.idm.geospatial.CoordinateOperations 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.idm.geospatial.CoordinateOperations in project collect by openforis.
the class Survey method initCoordinateOperations.
private void initCoordinateOperations() {
CoordinateOperations coordinateOperations = getContext().getCoordinateOperations();
coordinateOperations.registerSRS(getSpatialReferenceSystems());
}
use of org.openforis.idm.geospatial.CoordinateOperations 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;
}
}
Aggregations