Skip to content

Commit 36937a7

Browse files
committed
envelope static methods changed to instance & copy method
1 parent 4d4bfef commit 36937a7

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

src/main/java/mil/nga/sf/GeometryEnvelope.java

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,20 @@ public GeometryEnvelope(double minX, double minY, Double minZ, Double minM,
151151
/**
152152
* Copy Constructor
153153
*
154-
* @param boundingBox
154+
* @param envelope
155155
* Envelope to copy
156156
*/
157-
public GeometryEnvelope(GeometryEnvelope boundingBox) {
158-
this.minX = boundingBox.minX;
159-
this.maxX = boundingBox.maxX;
160-
this.minY = boundingBox.minY;
161-
this.maxY = boundingBox.maxY;
162-
this.hasZ = boundingBox.hasZ;
163-
this.minZ = boundingBox.minZ;
164-
this.maxZ = boundingBox.maxZ;
165-
this.hasM = boundingBox.hasM;
166-
this.minM = boundingBox.minM;
167-
this.maxM = boundingBox.maxM;
157+
public GeometryEnvelope(GeometryEnvelope envelope) {
158+
this.minX = envelope.minX;
159+
this.maxX = envelope.maxX;
160+
this.minY = envelope.minY;
161+
this.maxY = envelope.maxY;
162+
this.hasZ = envelope.hasZ;
163+
this.minZ = envelope.minZ;
164+
this.maxZ = envelope.maxZ;
165+
this.hasM = envelope.hasM;
166+
this.minM = envelope.minM;
167+
this.maxM = envelope.maxM;
168168
}
169169

170170
/**
@@ -396,47 +396,41 @@ public void setMaxM(Double maxM) {
396396
}
397397

398398
/**
399-
* Get the overlapping geometry envelope between the two envelopes
399+
* Get the overlapping geometry envelope with the provided envelope
400400
*
401401
* @param envelope
402-
* envelope 1
403-
* @param envelope2
404-
* envelope 2
402+
* envelope
405403
* @return geometry envelope
406404
*/
407-
public static GeometryEnvelope overlap(GeometryEnvelope envelope,
408-
GeometryEnvelope envelope2) {
405+
public GeometryEnvelope overlap(GeometryEnvelope envelope) {
409406

410-
double minX = Math.max(envelope.getMinX(), envelope2.getMinX());
411-
double maxX = Math.min(envelope.getMaxX(), envelope2.getMaxX());
412-
double minY = Math.max(envelope.getMinY(), envelope2.getMinY());
413-
double maxLatitude = Math.min(envelope.getMaxY(), envelope2.getMaxY());
407+
double minX = Math.max(getMinX(), envelope.getMinX());
408+
double maxX = Math.min(getMaxX(), envelope.getMaxX());
409+
double minY = Math.max(getMinY(), envelope.getMinY());
410+
double maxY = Math.min(getMaxY(), envelope.getMaxY());
414411

415412
GeometryEnvelope overlap = null;
416413

417-
if (minX < maxX && minY < maxLatitude) {
418-
overlap = new GeometryEnvelope(minX, minY, maxX, maxLatitude);
414+
if (minX < maxX && minY < maxY) {
415+
overlap = new GeometryEnvelope(minX, minY, maxX, maxY);
419416
}
420417

421418
return overlap;
422419
}
423420

424421
/**
425-
* Get the union geometry envelope combining the two envelopes
422+
* Get the union geometry envelope combined with the provided envelope
426423
*
427424
* @param envelope
428-
* envelope 1
429-
* @param envelope2
430-
* envelope 2
425+
* envelope
431426
* @return geometry envelope
432427
*/
433-
public static GeometryEnvelope union(GeometryEnvelope envelope,
434-
GeometryEnvelope envelope2) {
428+
public GeometryEnvelope union(GeometryEnvelope envelope) {
435429

436-
double minX = Math.min(envelope.getMinX(), envelope2.getMinX());
437-
double maxX = Math.max(envelope.getMaxX(), envelope2.getMaxX());
438-
double minY = Math.min(envelope.getMinY(), envelope2.getMinY());
439-
double maxY = Math.max(envelope.getMaxY(), envelope2.getMaxY());
430+
double minX = Math.min(getMinX(), envelope.getMinX());
431+
double maxX = Math.max(getMaxX(), envelope.getMaxX());
432+
double minY = Math.min(getMinY(), envelope.getMinY());
433+
double maxY = Math.max(getMaxY(), envelope.getMaxY());
440434

441435
GeometryEnvelope union = null;
442436

@@ -447,6 +441,15 @@ public static GeometryEnvelope union(GeometryEnvelope envelope,
447441
return union;
448442
}
449443

444+
/**
445+
* Copy the geometry envelope
446+
*
447+
* @return geometry envelope copy
448+
*/
449+
public GeometryEnvelope copy() {
450+
return new GeometryEnvelope(this);
451+
}
452+
450453
/**
451454
* {@inheritDoc}
452455
*/

0 commit comments

Comments
 (0)