Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ static BoundingBox merge(BoundingBox first, BoundingBox second) {
return first;
}

return new ImmutableBoundingBox.Builder()
.xmin(Math.min(first.getXmin(), second.getXmin()))
.ymin(Math.min(first.getYmin(), second.getYmin()))
.zmin(first.is3d() && second.is3d() ? Math.min(first.getZmin(), second.getZmin()) : null)
.xmax(Math.max(first.getXmax(), second.getXmax()))
.ymax(Math.max(first.getYmax(), second.getYmax()))
.zmax(first.is3d() && second.is3d() ? Math.max(first.getZmax(), second.getZmax()) : null)
.epsgCrs(first.getEpsgCrs())
.build();
Builder builder =
new ImmutableBoundingBox.Builder()
.xmin(Math.min(first.getXmin(), second.getXmin()))
.ymin(Math.min(first.getYmin(), second.getYmin()))
.xmax(Math.max(first.getXmax(), second.getXmax()))
.ymax(Math.max(first.getYmax(), second.getYmax()))
.epsgCrs(first.getEpsgCrs());

if (first.is3d() && second.is3d()) {
builder
.zmin(Math.min(first.getZmin(), second.getZmin()))
.zmax(Math.max(first.getZmax(), second.getZmax()));
}

return builder.build();
}

static Optional<BoundingBox> intersect2d(BoundingBox first, BoundingBox second, double buffer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ private BoundingBox transformBoundingBox2D(BoundingBox boundingBox)
return BoundingBox.of(xmin, ymin, xmax, ymax, getTargetCrs());
}

@SuppressWarnings("PMD.CyclomaticComplexity")
private BoundingBox transformBoundingBox3D(BoundingBox boundingBox)
throws CrsTransformationException {
assert (boundingBox.is3d());
assert boundingBox.is3d();

double[] llb =
this.transform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
/**
* @author fischer
*/
@SuppressWarnings({
"PMD.UseVarargs",
"PMD.ConstructorCallsOverridableMethod",
"PMD.ArrayIsStoredDirectly",
"PMD.MethodReturnsInternalArray"
})
public class CoordinateTuple {

protected double[] c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/**
* @author zahnen
*/
@SuppressWarnings("PMD.FieldNamingConventions")
public class CoordinateTupleWithPrecision extends CoordinateTuple {

private static DecimalFormat DEFAULT_FORMAT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
public class CrsTransformationException extends Exception {

private static final long serialVersionUID = 1L;

public CrsTransformationException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.math.BigInteger;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -21,6 +22,7 @@
@JsonDeserialize(builder = ImmutableEpsgCrs.Builder.class)
// TODO: test
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@SuppressWarnings("PMD.TooManyMethods")
public interface EpsgCrs {

enum Force {
Expand Down Expand Up @@ -55,21 +57,19 @@ static EpsgCrs fromString(String prefixedCode) {
return ogcCrs.get();
}

int code;
try {
code = Integer.parseInt(prefixedCode.substring(prefixedCode.lastIndexOf(":") + 1));
} catch (NumberFormatException e) {
try {
code = Integer.parseInt(prefixedCode.substring(prefixedCode.lastIndexOf("/") + 1));
} catch (NumberFormatException e2) {
try {
code = Integer.parseInt(prefixedCode);
} catch (NumberFormatException e3) {
throw new IllegalArgumentException("Could not parse CRS: " + prefixedCode);
}
}
int separator = Math.max(prefixedCode.lastIndexOf(':'), prefixedCode.lastIndexOf('/'));
String codeString = separator >= 0 ? prefixedCode.substring(separator + 1) : prefixedCode;

if (codeString.isEmpty() || !codeString.chars().allMatch(Character::isDigit)) {
throw new IllegalArgumentException("Could not parse CRS: " + prefixedCode);
}
return ImmutableEpsgCrs.of(code);

BigInteger code = new BigInteger(codeString);
if (code.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0) {
throw new IllegalArgumentException("Could not parse CRS: " + prefixedCode);
}

return ImmutableEpsgCrs.of(code.intValue());
}

static EpsgCrs fromString(String prefixedCode, String prefixedCodeVertical) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Objects;
import java.util.Optional;

@SuppressWarnings("PMD.FieldNamingConventions")
public interface OgcCrs {

EpsgCrs CRS84 = EpsgCrs.of(4326, Force.LON_LAT);
Expand Down
Loading
Loading