2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
.geom
;
9 import gov
.nasa
.worldwind
.cache
.Cacheable
;
10 import gov
.nasa
.worldwind
.globes
.Globe
;
11 import gov
.nasa
.worldwind
.tracks
.TrackPoint
;
12 import gov
.nasa
.worldwind
.util
.Logging
;
15 * <code>Sector</code> represents a rectangular reqion of latitude and longitude. The region is defined by four angles:
16 * its minimum and maximum latitude, its minimum and maximum longitude. The angles are assumed to be normalized to +/-
17 * 90 degrees latitude and +/- 180 degrees longitude. The minimums and maximums are relative to these ranges, e.g., -80
18 * is less than 20. Behavior of the class is undefined for angles outside these ranges. Normalization is not performed
19 * on the angles by this class, nor is it verifed by the class' methods. See {@link Angle} for a description of
22 * <code>Sector</code> instances are immutable. </p>
25 * @version $Id: Sector.java 3307 2007-10-16 14:43:49Z patrickmurris $
28 public class Sector
implements Cacheable
, Comparable
<Sector
>
31 * A <code>Sector</code> of latitude [-90 degrees, + 90 degrees] and longitude [-180 degrees, + 180 degrees].
33 public static final Sector FULL_SPHERE
= new Sector(Angle
.NEG90
, Angle
.POS90
, Angle
.NEG180
, Angle
.POS180
);
34 public static final Sector EMPTY_SECTOR
= new Sector(Angle
.ZERO
, Angle
.ZERO
, Angle
.ZERO
, Angle
.ZERO
);
36 private final Angle minLatitude
;
37 private final Angle maxLatitude
;
38 private final Angle minLongitude
;
39 private final Angle maxLongitude
;
40 private final Angle deltaLat
;
41 private final Angle deltaLon
;
44 * Creates a new <code>Sector</code> and initializes it to the specified angles. The angles are assumed to be
45 * normalized to +/- 90 degrees latitude and +/- 180 degrees longitude, but this method does not verify that.
47 * @param minLatitude the sector's minimum latitude in degrees.
48 * @param maxLatitude the sector's maximum latitude in degrees.
49 * @param minLongitude the sector's minimum longitude in degrees.
50 * @param maxLongitude the sector's maximum longitude in degrees.
51 * @return the new <code>Sector</code>
53 public static Sector
fromDegrees(double minLatitude
, double maxLatitude
, double minLongitude
,
56 return new Sector(Angle
.fromDegrees(minLatitude
), Angle
.fromDegrees(maxLatitude
), Angle
.fromDegrees(
57 minLongitude
), Angle
.fromDegrees(maxLongitude
));
61 * Creates a new <code>Sector</code> and initializes it to the specified angles. The angles are assumed to be
62 * normalized to +/- \u03c0/2 radians latitude and +/- \u03c0 radians longitude, but this method does not verify
65 * @param minLatitude the sector's minimum latitude in radians.
66 * @param maxLatitude the sector's maximum latitude in radians.
67 * @param minLongitude the sector's minimum longitude in radians.
68 * @param maxLongitude the sector's maximum longitude in radians.
69 * @return the new <code>Sector</code>
71 public static Sector
fromRadians(double minLatitude
, double maxLatitude
, double minLongitude
,
74 return new Sector(Angle
.fromRadians(minLatitude
), Angle
.fromRadians(maxLatitude
), Angle
.fromRadians(
75 minLongitude
), Angle
.fromRadians(maxLongitude
));
78 public static Sector
boundingSector(java
.util
.Iterator
<TrackPoint
> positions
)
80 if (positions
== null)
82 String message
= Logging
.getMessage("nullValue.TracksPointsIteratorNull");
83 Logging
.logger().severe(message
);
84 throw new IllegalArgumentException(message
);
87 if (!positions
.hasNext())
90 TrackPoint position
= positions
.next();
91 double minLat
= position
.getLatitude();
92 double minLon
= position
.getLongitude();
93 double maxLat
= minLat
;
94 double maxLon
= minLon
;
96 while (positions
.hasNext())
98 TrackPoint p
= positions
.next();
99 double lat
= p
.getLatitude();
102 else if (lat
> maxLat
)
105 double lon
= p
.getLongitude();
108 else if (lon
> maxLon
)
112 return Sector
.fromDegrees(minLat
, maxLat
, minLon
, maxLon
);
115 public static Sector
boundingSectorfromLatLons(Iterable
<LatLon
> positions
)
117 if (positions
== null)
119 String message
= Logging
.getMessage("nullValue.PositionsListIsNull");
120 Logging
.logger().severe(message
);
121 throw new IllegalArgumentException(message
);
124 double minLat
= Angle
.POS90
.getDegrees();
125 double minLon
= Angle
.POS180
.getDegrees();
126 double maxLat
= Angle
.NEG180
.getDegrees();
127 double maxLon
= Angle
.NEG180
.getDegrees();
129 for (LatLon p
: positions
)
131 double lat
= p
.getLatitude().getDegrees();
137 double lon
= p
.getLongitude().getDegrees();
144 if (minLat
== maxLat
&& minLon
== maxLon
)
147 return Sector
.fromDegrees(minLat
, maxLat
, minLon
, maxLon
);
150 public static Sector
boundingSectorfromPositions(Iterable
<Position
> positions
)
152 if (positions
== null)
154 String message
= Logging
.getMessage("nullValue.PositionsListIsNull");
155 Logging
.logger().severe(message
);
156 throw new IllegalArgumentException(message
);
159 double minLat
= Angle
.POS90
.getDegrees();
160 double minLon
= Angle
.POS180
.getDegrees();
161 double maxLat
= Angle
.NEG180
.getDegrees();
162 double maxLon
= Angle
.NEG180
.getDegrees();
164 for (Position p
: positions
)
166 double lat
= p
.getLatitude().getDegrees();
172 double lon
= p
.getLongitude().getDegrees();
179 if (minLat
== maxLat
&& minLon
== maxLon
)
182 return Sector
.fromDegrees(minLat
, maxLat
, minLon
, maxLon
);
185 public static Sector
boundingSector(Position pA
, Position pB
)
187 if (pA
== null || pB
== null)
189 String message
= Logging
.getMessage("nullValue.PositionsListIsNull");
190 Logging
.logger().severe(message
);
191 throw new IllegalArgumentException(message
);
194 double minLat
= pA
.getLatitude().degrees
;
195 double minLon
= pA
.getLongitude().degrees
;
196 double maxLat
= pA
.getLatitude().degrees
;
197 double maxLon
= pA
.getLongitude().degrees
;
199 if (pB
.getLatitude().degrees
< minLat
)
200 minLat
= pB
.getLatitude().degrees
;
201 else if (pB
.getLatitude().degrees
> maxLat
)
202 maxLat
= pB
.getLatitude().degrees
;
204 if (pB
.getLongitude().degrees
< minLon
)
205 minLon
= pB
.getLongitude().degrees
;
206 else if (pB
.getLongitude().degrees
> maxLon
)
207 maxLon
= pB
.getLongitude().degrees
;
209 if (minLat
== maxLat
&& minLon
== maxLon
)
212 return Sector
.fromDegrees(minLat
, maxLat
, minLon
, maxLon
);
216 * Creates a new <code>Sector</code> and initializes it to the specified angles. The angles are assumed to be
217 * normalized to +/- 90 degrees latitude and +/- 180 degrees longitude, but this method does not verify that.
219 * @param minLatitude the sector's minimum latitude.
220 * @param maxLatitude the sector's maximum latitude.
221 * @param minLongitude the sector's minimum longitude.
222 * @param maxLongitude the sector's maximum longitude.
223 * @throws IllegalArgumentException if any of the angles are null
225 public Sector(Angle minLatitude
, Angle maxLatitude
, Angle minLongitude
, Angle maxLongitude
)
227 if (minLatitude
== null || maxLatitude
== null || minLongitude
== null || maxLongitude
== null)
229 String message
= Logging
.getMessage("nullValue.InputAnglesNull");
230 Logging
.logger().severe(message
);
231 throw new IllegalArgumentException(message
);
234 this.minLatitude
= minLatitude
;
235 this.maxLatitude
= maxLatitude
;
236 this.minLongitude
= minLongitude
;
237 this.maxLongitude
= maxLongitude
;
238 this.deltaLat
= Angle
.fromDegrees(this.maxLatitude
.degrees
- this.minLatitude
.degrees
);
239 this.deltaLon
= Angle
.fromDegrees(this.maxLongitude
.degrees
- this.minLongitude
.degrees
);
242 public Sector(Sector sector
)
246 String message
= Logging
.getMessage("nullValue.SectorIsNull");
247 Logging
.logger().severe(message
);
248 throw new IllegalArgumentException(message
);
251 this.minLatitude
= new Angle(sector
.getMinLatitude());
252 this.maxLatitude
= new Angle(sector
.getMaxLatitude());
253 this.minLongitude
= new Angle(sector
.getMinLongitude());
254 this.maxLongitude
= new Angle(sector
.getMaxLongitude());
255 this.deltaLat
= Angle
.fromDegrees(this.maxLatitude
.degrees
- this.minLatitude
.degrees
);
256 this.deltaLon
= Angle
.fromDegrees(this.maxLongitude
.degrees
- this.minLongitude
.degrees
);
260 * Returns the sector's minimum latitude.
262 * @return The sector's minimum latitude.
264 public final Angle
getMinLatitude()
270 * Returns the sector's minimum longitude.
272 * @return The sector's minimum longitude.
274 public final Angle
getMinLongitude()
280 * Returns the sector's maximum latitude.
282 * @return The sector's maximum latitude.
284 public final Angle
getMaxLatitude()
290 * Returns the sector's maximum longitude.
292 * @return The sector's maximum longitude.
294 public final Angle
getMaxLongitude()
300 * Returns the angular difference between the sector's minimum and maximum latitudes: max - min
302 * @return The angular difference between the sector's minimum and maximum latitudes.
304 public final Angle
getDeltaLat()
306 return this.deltaLat
;//Angle.fromDegrees(this.maxLatitude.degrees - this.minLatitude.degrees);
309 public final double getDeltaLatDegrees()
311 return this.deltaLat
.degrees
;//this.maxLatitude.degrees - this.minLatitude.degrees;
314 public final double getDeltaLatRadians()
316 return this.deltaLat
.radians
;//this.maxLatitude.radians - this.minLatitude.radians;
320 * Returns the angular difference between the sector's minimum and maximum longitudes: max - min.
322 * @return The angular difference between the sector's minimum and maximum longitudes
324 public final Angle
getDeltaLon()
326 return this.deltaLon
;//Angle.fromDegrees(this.maxLongitude.degrees - this.minLongitude.degrees);
329 public final double getDeltaLonDegrees()
331 return this.deltaLon
.degrees
;//this.maxLongitude.degrees - this.minLongitude.degrees;
334 public final double getDeltaLonRadians()
336 return this.deltaLon
.radians
;//this.maxLongitude.radians - this.minLongitude.radians;
340 * Returns the latitude and longitude of the sector's angular center: (minimum latitude + maximum latitude) / 2,
341 * (minimum longitude + maximum longitude) / 2.
343 * @return The latitude and longitude of the sector's angular center
345 public final LatLon
getCentroid()
347 Angle la
= Angle
.fromDegrees(0.5 * (this.getMaxLatitude().degrees
+ this.getMinLatitude().degrees
));
348 Angle lo
= Angle
.fromDegrees(0.5 * (this.getMaxLongitude().degrees
+ this.getMinLongitude().degrees
));
349 return new LatLon(la
, lo
);
352 public Vec4
computeCenterPoint(Globe globe
)
356 String msg
= Logging
.getMessage("nullValue.GlobeIsNull");
357 Logging
.logger().severe(msg
);
358 throw new IllegalArgumentException(msg
);
361 double lat
= 0.5 * (this.minLatitude
.degrees
+ this.maxLatitude
.degrees
);
362 double lon
= 0.5 * (this.minLongitude
.degrees
+ this.maxLongitude
.degrees
);
364 Angle cLat
= Angle
.fromDegrees(lat
);
365 Angle cLon
= Angle
.fromDegrees(lon
);
366 return globe
.computePointFromPosition(cLat
, cLon
, globe
.getElevation(cLat
, cLon
));
369 public Vec4
[] computeCornerPoints(Globe globe
)
373 String msg
= Logging
.getMessage("nullValue.GlobeIsNull");
374 Logging
.logger().severe(msg
);
375 throw new IllegalArgumentException(msg
);
377 Vec4
[] corners
= new Vec4
[4];
379 Angle minLat
= this.minLatitude
;
380 Angle maxLat
= this.maxLatitude
;
381 Angle minLon
= this.minLongitude
;
382 Angle maxLon
= this.maxLongitude
;
384 corners
[0] = globe
.computePointFromPosition(minLat
, minLon
, globe
.getElevation(minLat
, minLon
));
385 corners
[1] = globe
.computePointFromPosition(minLat
, maxLon
, globe
.getElevation(minLat
, maxLon
));
386 corners
[2] = globe
.computePointFromPosition(maxLat
, maxLon
, globe
.getElevation(maxLat
, maxLon
));
387 corners
[3] = globe
.computePointFromPosition(maxLat
, minLon
, globe
.getElevation(maxLat
, minLon
));
393 * Returns a sphere that minimally surrounds the sector at a specified vertical exaggeration.
395 * @param globe the globe the sector is associated with
396 * @param verticalExaggeration the vertical exaggeration to apply to the globe's elevations when computing the
398 * @param sector the sector to return the bounding sphere for.
399 * @return The minimal bounding sphere in Cartesian coordinates.
400 * @throws IllegalArgumentException if <code>globe</code> or <code>sector</code> is null
402 static public Extent
computeBoundingSphere(Globe globe
, double verticalExaggeration
, Sector sector
)
406 String msg
= Logging
.getMessage("nullValue.GlobeIsNull");
407 Logging
.logger().severe(msg
);
408 throw new IllegalArgumentException(msg
);
412 String msg
= Logging
.getMessage("nullValue.SectorIsNull");
413 Logging
.logger().severe(msg
);
414 throw new IllegalArgumentException(msg
);
417 LatLon center
= sector
.getCentroid();
418 double maxHeight
= globe
.getMaxElevation(sector
) * verticalExaggeration
;
419 double minHeight
= globe
.getMinElevation(sector
) * verticalExaggeration
;
421 Vec4
[] points
= new Vec4
[9];
422 points
[0] = globe
.computePointFromPosition(center
.getLatitude(), center
.getLongitude(), maxHeight
);
423 points
[1] = globe
.computePointFromPosition(sector
.getMaxLatitude(), sector
.getMinLongitude(), maxHeight
);
424 points
[2] = globe
.computePointFromPosition(sector
.getMinLatitude(), sector
.getMaxLongitude(), maxHeight
);
425 points
[3] = globe
.computePointFromPosition(sector
.getMinLatitude(), sector
.getMinLongitude(), maxHeight
);
426 points
[4] = globe
.computePointFromPosition(sector
.getMaxLatitude(), sector
.getMaxLongitude(), maxHeight
);
427 points
[5] = globe
.computePointFromPosition(sector
.getMaxLatitude(), sector
.getMinLongitude(), minHeight
);
428 points
[6] = globe
.computePointFromPosition(sector
.getMinLatitude(), sector
.getMaxLongitude(), minHeight
);
429 points
[7] = globe
.computePointFromPosition(sector
.getMinLatitude(), sector
.getMinLongitude(), minHeight
);
430 points
[8] = globe
.computePointFromPosition(sector
.getMaxLatitude(), sector
.getMaxLongitude(), minHeight
);
432 return Sphere
.createBoundingSphere(points
);
435 public final boolean contains(Angle latitude
, Angle longitude
)
437 if (latitude
== null || longitude
== null)
439 String message
= Logging
.getMessage("nullValue.LatLonIsNull");
440 Logging
.logger().severe(message
);
441 throw new IllegalArgumentException(message
);
444 return latitude
.degrees
>= this.minLatitude
.degrees
445 && latitude
.degrees
<= this.maxLatitude
.degrees
446 && longitude
.degrees
>= this.minLongitude
.degrees
447 && longitude
.degrees
<= this.maxLongitude
.degrees
;
451 * Determines whether a latitude/longitude position is within the sector. The sector's angles are assumed to be
452 * normalized to +/- 90 degrees latitude and +/- 180 degrees longitude. The result of the operation is undefined if
455 * @param latLon the position to test, with angles normalized to +/- π latitude and +/- 2π longitude.
456 * @return <code>true</code> if the position is within the sector, <code>false</code> otherwise.
457 * @throws IllegalArgumentException if <code>latlon</code> is null.
459 public final boolean contains(LatLon latLon
)
463 String message
= Logging
.getMessage("nullValue.LatLonIsNull");
464 Logging
.logger().severe(message
);
465 throw new IllegalArgumentException(message
);
468 return this.contains(latLon
.getLatitude(), latLon
.getLongitude());
472 * Determines whether a latitude/longitude postion expressed in radians is within the sector. The sector's angles
473 * are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude. The result of the
474 * operation is undefined if they are not.
476 * @param radiansLatitude the latitude in radians of the position to test, normalized +/- π.
477 * @param radiansLongitude the longitude in radians of the position to test, normalized +/- 2π.
478 * @return <code>true</code> if the position is within the sector, <code>false</code> otherwise.
480 public final boolean containsRadians(double radiansLatitude
, double radiansLongitude
)
482 return radiansLatitude
>= this.minLatitude
.radians
&& radiansLatitude
<= this.maxLatitude
.radians
483 && radiansLongitude
>= this.minLongitude
.radians
&& radiansLongitude
<= this.maxLongitude
.radians
;
486 public final boolean containsDegrees(double degreesLatitude
, double degreesLongitude
)
488 return degreesLatitude
>= this.minLatitude
.degrees
&& degreesLatitude
<= this.maxLatitude
.degrees
489 && degreesLongitude
>= this.minLongitude
.degrees
&& degreesLongitude
<= this.maxLongitude
.degrees
;
493 * Determines whether this sector intersects another sector's range of latitude and longitude. The sector's angles
494 * are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude. The result of the
495 * operation is undefined if they are not.
497 * @param that the sector to test for intersection.
498 * @return <code>true</code> if the sectors intersect, otherwise <code>false</code>.
500 public boolean intersects(Sector that
)
505 // Assumes normalized angles -- [-180, 180], [-90, 90] // TODO: have Angle normalize values when set
506 if (that
.maxLongitude
.degrees
< this.minLongitude
.degrees
)
508 if (that
.minLongitude
.degrees
> this.maxLongitude
.degrees
)
510 if (that
.maxLatitude
.degrees
< this.minLatitude
.degrees
)
512 //noinspection RedundantIfStatement
513 if (that
.minLatitude
.degrees
> this.maxLatitude
.degrees
)
520 * Returns a new sector whose angles are the extremes of the this sector and another. The new sector's minimum
521 * latitude and longitude will be the minimum of the two sectors. The new sector's maximum latitude and longitude
522 * will be the maximum of the two sectors. The sectors are assumed to be normalized to +/- 90 degrees latitude and
523 * +/- 180 degrees longitude. The result of the operation is undefined if they are not.
525 * @param that the sector to join with <code>this</code>.
526 * @return A new sector formed from the extremes of the two sectors, or <code>this</code> if the incoming sector is
529 public final Sector
union(Sector that
)
534 Angle minLat
= this.minLatitude
;
535 Angle maxLat
= this.maxLatitude
;
536 Angle minLon
= this.minLongitude
;
537 Angle maxLon
= this.maxLongitude
;
539 if (that
.minLatitude
.degrees
< this.minLatitude
.degrees
)
540 minLat
= that
.minLatitude
;
541 if (that
.maxLatitude
.degrees
> this.maxLatitude
.degrees
)
542 maxLat
= that
.maxLatitude
;
543 if (that
.minLongitude
.degrees
< this.minLongitude
.degrees
)
544 minLon
= that
.minLongitude
;
545 if (that
.maxLongitude
.degrees
> this.maxLongitude
.degrees
)
546 maxLon
= that
.maxLongitude
;
548 return new Sector(minLat
, maxLat
, minLon
, maxLon
);
551 public final Sector
union(Angle latitude
, Angle longitude
)
553 if (latitude
== null || longitude
== null)
556 Angle minLat
= this.minLatitude
;
557 Angle maxLat
= this.maxLatitude
;
558 Angle minLon
= this.minLongitude
;
559 Angle maxLon
= this.maxLongitude
;
561 if (latitude
.degrees
< this.minLatitude
.degrees
)
563 if (latitude
.degrees
> this.maxLatitude
.degrees
)
565 if (longitude
.degrees
< this.minLongitude
.degrees
)
567 if (longitude
.degrees
> this.maxLongitude
.degrees
)
570 return new Sector(minLat
, maxLat
, minLon
, maxLon
);
573 public static Sector
union(Sector sectorA
, Sector sectorB
)
575 if (sectorA
== null || sectorB
== null)
577 if (sectorA
== sectorB
)
578 return null; // TODO: throw exception
580 return sectorB
== null ? sectorA
: sectorB
;
583 return sectorA
.union(sectorB
);
586 public final Sector
intersection(Sector that
)
591 Angle minLat
, maxLat
;
592 minLat
= (this.minLatitude
.degrees
> that
.minLatitude
.degrees
) ?
this.minLatitude
: that
.minLatitude
;
593 maxLat
= (this.maxLatitude
.degrees
< that
.maxLatitude
.degrees
) ?
this.maxLatitude
: that
.maxLatitude
;
594 if (minLat
.degrees
> maxLat
.degrees
)
597 Angle minLon
, maxLon
;
598 minLon
= (this.minLongitude
.degrees
> that
.minLongitude
.degrees
) ?
this.minLongitude
: that
.minLongitude
;
599 maxLon
= (this.maxLongitude
.degrees
< that
.maxLongitude
.degrees
) ?
this.maxLongitude
: that
.maxLongitude
;
600 if (minLon
.degrees
> maxLon
.degrees
)
603 return new Sector(minLat
, maxLat
, minLon
, maxLon
);
606 public final Sector
intersection(Angle latitude
, Angle longitude
)
608 if (latitude
== null || longitude
== null)
611 if (!this.contains(latitude
, longitude
))
613 return new Sector(latitude
, latitude
, longitude
, longitude
);
616 public final Sector
[] subdivide()
618 Angle midLat
= Angle
.average(this.minLatitude
, this.maxLatitude
);
619 Angle midLon
= Angle
.average(this.minLongitude
, this.maxLongitude
);
621 Sector
[] sectors
= new Sector
[4];
622 sectors
[0] = new Sector(this.minLatitude
, midLat
, this.minLongitude
, midLon
);
623 sectors
[1] = new Sector(this.minLatitude
, midLat
, midLon
, this.maxLongitude
);
624 sectors
[2] = new Sector(midLat
, this.maxLatitude
, this.minLongitude
, midLon
);
625 sectors
[3] = new Sector(midLat
, this.maxLatitude
, midLon
, this.maxLongitude
);
631 * Returns a string indicating the sector's angles.
633 * @return A string indicating the sector's angles.
636 public String
toString()
638 java
.lang
.StringBuffer sb
= new java
.lang
.StringBuffer();
640 sb
.append(this.minLatitude
.toString());
642 sb
.append(this.minLongitude
.toString());
648 sb
.append(this.maxLatitude
.toString());
650 sb
.append(this.maxLongitude
.toString());
653 return sb
.toString();
657 * Retrieve the size of this object in bytes. This implementation returns an exact value of the object's size.
659 * @return the size of this object in bytes
661 public long getSizeInBytes()
663 return 4 * minLatitude
.getSizeInBytes(); // 4 angles
667 * Compares this sector to a specified sector according to their minimum latitude, minimum longitude, maximum
668 * latitude, and maximum longitude, respectively.
670 * @param that the <code>Sector</code> to compareTo with <code>this</code>.
671 * @return -1 if this sector compares less than that specified, 0 if they're equal, and 1 if it compares greater.
672 * @throws IllegalArgumentException if <code>that</code> is null
674 public int compareTo(Sector that
)
678 String msg
= Logging
.getMessage("nullValue.SectorIsNull");
679 Logging
.logger().severe(msg
);
680 throw new IllegalArgumentException(msg
);
683 if (this.getMinLatitude().compareTo(that
.getMinLatitude()) < 0)
686 if (this.getMinLatitude().compareTo(that
.getMinLatitude()) > 0)
689 if (this.getMinLongitude().compareTo(that
.getMinLongitude()) < 0)
692 if (this.getMinLongitude().compareTo(that
.getMinLongitude()) > 0)
695 if (this.getMaxLatitude().compareTo(that
.getMaxLatitude()) < 0)
698 if (this.getMaxLatitude().compareTo(that
.getMaxLatitude()) > 0)
701 if (this.getMaxLongitude().compareTo(that
.getMaxLongitude()) < 0)
704 if (this.getMaxLongitude().compareTo(that
.getMaxLongitude()) > 0)
711 * Tests the equality of the sectors' angles. Sectors are equal if all of their corresponding angles are equal.
713 * @param o the sector to compareTo with <code>this</code>.
714 * @return <code>true</code> if the four corresponding angles of each sector are equal, <code>false</code>
718 public boolean equals(Object o
)
722 if (o
== null || getClass() != o
.getClass())
725 final gov
.nasa
.worldwind
.geom
.Sector sector
= (gov
.nasa
.worldwind
.geom
.Sector
) o
;
727 if (!maxLatitude
.equals(sector
.maxLatitude
))
729 if (!maxLongitude
.equals(sector
.maxLongitude
))
731 if (!minLatitude
.equals(sector
.minLatitude
))
733 //noinspection RedundantIfStatement
734 if (!minLongitude
.equals(sector
.minLongitude
))
741 * Computes a hash code from the sector's four angles.
743 * @return a hash code incorporating the sector's four angles.
746 public int hashCode()
749 result
= minLatitude
.hashCode();
750 result
= 29 * result
+ maxLatitude
.hashCode();
751 result
= 29 * result
+ minLongitude
.hashCode();
752 result
= 29 * result
+ maxLongitude
.hashCode();