Skip to content

Commit cfedfce

Browse files
committed
minor change to inlcude method of envelope
1 parent 6267222 commit cfedfce

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

src/main/java/org/xmlobjects/gml/model/geometry/Envelope.java

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,24 +265,32 @@ public Envelope include(Envelope other) {
265265
public Envelope include(List<Double> ordinates) {
266266
if (ordinates != null && !ordinates.isEmpty()) {
267267
int dimension = Math.min(lowerCorner.getValue().size(), upperCorner.getValue().size());
268-
for (int i = 0; i < ordinates.size(); i++) {
269-
double ordinate = ordinates.get(i);
270-
if (i < dimension) {
271-
if (ordinate < lowerCorner.getValue().get(i)) {
272-
lowerCorner.getValue().set(i, ordinate);
268+
if (dimension == 0) {
269+
lowerCorner.setValue(ordinates);
270+
upperCorner.setValue(ordinates);
271+
} else {
272+
for (int i = 0; i < ordinates.size(); i++) {
273+
double ordinate = ordinates.get(i);
274+
if (i < dimension) {
275+
if (ordinate < lowerCorner.getValue().get(i)) {
276+
lowerCorner.getValue().set(i, ordinate);
277+
}
278+
279+
if (ordinate > upperCorner.getValue().get(i)) {
280+
upperCorner.getValue().set(i, ordinate);
281+
}
282+
} else {
283+
if (lowerCorner.getValue().size() > i) {
284+
lowerCorner.setValue(lowerCorner.getValue().subList(0, i));
285+
}
286+
287+
if (upperCorner.getValue().size() > i) {
288+
upperCorner.setValue(upperCorner.getValue().subList(0, i));
289+
}
290+
291+
lowerCorner.getValue().add(ordinate);
292+
upperCorner.getValue().add(ordinate);
273293
}
274-
275-
if (ordinate > upperCorner.getValue().get(i)) {
276-
upperCorner.getValue().set(i, ordinate);
277-
}
278-
} else {
279-
if (dimension > 0) {
280-
lowerCorner.setValue(lowerCorner.getValue().subList(0, i));
281-
upperCorner.setValue(upperCorner.getValue().subList(0, i));
282-
}
283-
284-
lowerCorner.getValue().add(ordinate);
285-
upperCorner.getValue().add(ordinate);
286294
}
287295
}
288296
}

0 commit comments

Comments
 (0)