use of de.ii.xtraplatform.features.domain.ImmutableFeatureQuery in project ldproxy by interactive-instruments.
the class FeaturesQueryImpl method processCoordinatePrecision.
private ImmutableFeatureQuery.Builder processCoordinatePrecision(ImmutableFeatureQuery.Builder queryBuilder, Map<String, Integer> coordinatePrecision) {
// check, if we need to add a precision value; for this we need the target CRS,
// so we need to build the query to get the CRS
ImmutableFeatureQuery query = queryBuilder.build();
if (!coordinatePrecision.isEmpty() && query.getCrs().isPresent()) {
Integer precision;
List<Unit<?>> units = crsInfo.getAxisUnits(query.getCrs().get());
ImmutableList.Builder<Integer> precisionListBuilder = new ImmutableList.Builder<>();
for (Unit<?> unit : units) {
if (unit.equals(Units.METRE)) {
precision = coordinatePrecision.get("meter");
if (Objects.isNull(precision))
precision = coordinatePrecision.get("metre");
} else if (unit.equals(Units.DEGREE)) {
precision = coordinatePrecision.get("degree");
} else {
LOGGER.debug("Coordinate precision could not be set, unrecognised unit found: '{}'.", unit.getName());
return queryBuilder;
}
precisionListBuilder.add(precision);
}
List<Integer> precisionList = precisionListBuilder.build();
if (!precisionList.isEmpty()) {
queryBuilder.geometryPrecision(precisionList);
}
}
return queryBuilder;
}
Aggregations