Skip to content

Commit d7b3b71

Browse files
committed
Fix linting issues
1 parent 9cc63ca commit d7b3b71

File tree

5 files changed

+57
-66
lines changed

5 files changed

+57
-66
lines changed

src/main/kotlin/gov/nasa/worldwind/geom/Angle.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ class Angle : Comparable<Angle?> {
117117

118118
override fun equals(other: Any?): Boolean {
119119
if (this === other) return true
120-
if (other == null || javaClass != other.javaClass) return false
121-
122-
val angle = other as Angle
120+
if (other !is Angle) return false
121+
val angle = other
123122

124123
return angle.degrees == this.degrees
125124
}
@@ -159,7 +158,7 @@ class Angle : Comparable<Angle?> {
159158
return Angle(RADIANS_TO_DEGREES * radians, radians)
160159
}
161160

162-
private const val HALF_PI = Math.PI / 2
161+
private const val HALF_PI = PI / 2
163162

164163
fun fromDegreesLatitude(degrees: Double): Angle {
165164
var degrees = degrees
@@ -174,7 +173,7 @@ class Angle : Comparable<Angle?> {
174173
var degrees = degrees
175174
degrees = if (degrees < -180) -180.0 else if (degrees > 180) 180.0 else degrees
176175
var radians: Double = DEGREES_TO_RADIANS * degrees
177-
radians = if (radians < -Math.PI) -Math.PI else if (radians > Math.PI) Math.PI else radians
176+
radians = if (radians < -PI) -PI else if (radians > PI) PI else radians
178177

179178
return Angle(degrees, radians)
180179
}

src/main/kotlin/gov/nasa/worldwind/geom/LatLon.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ open class LatLon {
5353
return LatLon(lat, lon)
5454
}
5555

56-
open fun add(that: Position): LatLon? {
56+
open fun add(that: Position): LatLon {
5757

5858
val lat = Angle.normalizedLatitude(this.latitude.add(that.latitude))
5959
val lon = Angle.normalizedLongitude(this.longitude.add(that.longitude))
6060

6161
return LatLon(lat, lon)
6262
}
6363

64-
open fun subtract(that: Position): LatLon? {
64+
open fun subtract(that: Position): LatLon {
6565

6666
val lat = Angle.normalizedLatitude(this.latitude.subtract(that.latitude))
6767
val lon = Angle.normalizedLongitude(this.longitude.subtract(that.longitude))
@@ -77,12 +77,9 @@ open class LatLon {
7777

7878
override fun equals(other: Any?): Boolean {
7979
if (this === other) return true
80-
if (other == null || javaClass != other.javaClass) return false
81-
82-
val latLon = other as LatLon
83-
84-
if (latitude != latLon.latitude) return false
85-
if (longitude != latLon.longitude) return false
80+
if (other !is LatLon) return false
81+
if (latitude != other.latitude) return false
82+
if (longitude != other.longitude) return false
8683

8784
return true
8885
}

src/main/kotlin/gov/nasa/worldwind/geom/Position.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ class Position(
2929

3030
override fun equals(other: Any?): Boolean {
3131
if (this === other) return true
32-
if (other == null || javaClass != other.javaClass) return false
32+
if (other !is Position) return false
3333
if (!super.equals(other)) return false
3434

35-
val position = other as Position
36-
37-
return position.altitude == this.altitude
35+
return other.altitude == this.altitude
3836
}
3937

4038
override fun hashCode(): Int {

src/main/kotlin/gov/nasa/worldwind/geom/coords/UTMCoord.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,11 @@ class UTMCoord
3737
* @param hemisphere the hemisphere, either [AVKey.NORTH] or [ ][AVKey.SOUTH].
3838
* @param easting the easting distance in meters
3939
* @param northing the northing distance in meters.
40-
* @param centralMeridian the cntral meridian `Angle`.
40+
* @param centralMeridian the central meridian `Angle`.
4141
*
4242
* @throws IllegalArgumentException if `latitude` or `longitude` is null.
4343
*/
4444
init {
45-
require(!(latitude == null || longitude == null)) { "Latitude Or Longitude Is Null" }
46-
4745
this.latitude = latitude
4846
this.longitude = longitude
4947
this.hemisphere = hemisphere
@@ -75,7 +73,6 @@ class UTMCoord
7573
* UTM coordinates fails.
7674
*/
7775
fun fromLatLon(latitude: Angle, longitude: Angle): UTMCoord {
78-
require(!(latitude == null || longitude == null)) { "Latitude Or Longitude Is Null" }
7976

8077
val converter = UTMCoordConverter()
8178
val err = converter.convertGeodeticToUTM(latitude.radians, longitude.radians)

src/main/kotlin/gov/nasa/worldwind/geom/coords/UTMCoordConverter.kt

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -112,74 +112,74 @@ internal class UTMCoordConverter {
112112
*
113113
* @return error code
114114
*/
115-
fun convertGeodeticToUTM(Latitude: Double, Longitude: Double): Long {
116-
var Longitude = Longitude
117-
val Lat_Degrees: Long
118-
val Long_Degrees: Long
119-
var temp_zone: Long
120-
var Error_Code = UTM_NO_ERROR.toLong()
121-
val Origin_Latitude = 0.0
122-
val False_Easting = 500000.0
123-
var False_Northing = 0.0
124-
val Scale = 0.9996
115+
fun convertGeodeticToUTM(latitude: Double, longitude: Double): Long {
116+
var lon = longitude
117+
val latDegrees: Long
118+
val longDegrees: Long
119+
var tempZone: Long
120+
var errorCode = UTM_NO_ERROR.toLong()
121+
val originLatitude = 0.0
122+
val falseEasting = 500000.0
123+
var falseNorthing = 0.0
124+
val scale = 0.9996
125125

126-
if ((Latitude < MIN_LAT) || (Latitude > MAX_LAT)) { /* Latitude out of range */
127-
Error_Code = Error_Code or UTM_LAT_ERROR.toLong()
126+
if ((latitude < MIN_LAT) || (latitude > MAX_LAT)) { /* Latitude out of range */
127+
errorCode = errorCode or UTM_LAT_ERROR.toLong()
128128
}
129-
if ((Longitude < -PI) || (Longitude > (2 * PI))) { /* Longitude out of range */
130-
Error_Code = Error_Code or UTM_LON_ERROR.toLong()
129+
if ((lon < -PI) || (lon > (2 * PI))) { /* Longitude out of range */
130+
errorCode = errorCode or UTM_LON_ERROR.toLong()
131131
}
132-
if (Error_Code == UTM_NO_ERROR.toLong()) { /* no errors */
133-
if (Longitude < 0) Longitude += (2 * PI) + 1.0e-10
134-
Lat_Degrees = (Latitude * 180.0 / PI).toLong()
135-
Long_Degrees = (Longitude * 180.0 / PI).toLong()
132+
if (errorCode == UTM_NO_ERROR.toLong()) { /* no errors */
133+
if (lon < 0) lon += (2 * PI) + 1.0e-10
134+
latDegrees = (latitude * 180.0 / PI).toLong()
135+
longDegrees = (lon * 180.0 / PI).toLong()
136136

137-
if (Longitude < PI) temp_zone = (31 + ((Longitude * 180.0 / PI) / 6.0)).toLong()
138-
else temp_zone = (((Longitude * 180.0 / PI) / 6.0) - 29).toLong()
139-
if (temp_zone > 60) temp_zone = 1
137+
tempZone = if (lon < PI) (31 + ((lon * 180.0 / PI) / 6.0)).toLong()
138+
else (((lon * 180.0 / PI) / 6.0) - 29).toLong()
139+
if (tempZone > 60) tempZone = 1
140140
/* UTM special cases */
141-
if ((Lat_Degrees > 55) && (Lat_Degrees < 64) && (Long_Degrees > -1) && (Long_Degrees < 3)) temp_zone = 31
142-
if ((Lat_Degrees > 55) && (Lat_Degrees < 64) && (Long_Degrees > 2) && (Long_Degrees < 12)) temp_zone = 32
143-
if ((Lat_Degrees > 71) && (Long_Degrees > -1) && (Long_Degrees < 9)) temp_zone = 31
144-
if ((Lat_Degrees > 71) && (Long_Degrees > 8) && (Long_Degrees < 21)) temp_zone = 33
145-
if ((Lat_Degrees > 71) && (Long_Degrees > 20) && (Long_Degrees < 33)) temp_zone = 35
146-
if ((Lat_Degrees > 71) && (Long_Degrees > 32) && (Long_Degrees < 42)) temp_zone = 37
141+
if ((latDegrees > 55) && (latDegrees < 64) && (longDegrees > -1) && (longDegrees < 3)) tempZone = 31
142+
if ((latDegrees > 55) && (latDegrees < 64) && (longDegrees > 2) && (longDegrees < 12)) tempZone = 32
143+
if ((latDegrees > 71) && (longDegrees > -1) && (longDegrees < 9)) tempZone = 31
144+
if ((latDegrees > 71) && (longDegrees > 8) && (longDegrees < 21)) tempZone = 33
145+
if ((latDegrees > 71) && (longDegrees > 20) && (longDegrees < 33)) tempZone = 35
146+
if ((latDegrees > 71) && (longDegrees > 32) && (longDegrees < 42)) tempZone = 37
147147

148148
if (UTM_Override != 0L) {
149-
if ((temp_zone == 1L) && (UTM_Override == 60L)) temp_zone = UTM_Override
150-
else if ((temp_zone == 60L) && (UTM_Override == 1L)) temp_zone = UTM_Override
151-
else if (((temp_zone - 1) <= UTM_Override) && (UTM_Override <= (temp_zone + 1))) temp_zone =
149+
if ((tempZone == 1L) && (UTM_Override == 60L)) tempZone = UTM_Override
150+
else if ((tempZone == 60L) && (UTM_Override == 1L)) tempZone = UTM_Override
151+
else if (((tempZone - 1) <= UTM_Override) && (UTM_Override <= (tempZone + 1))) tempZone =
152152
UTM_Override
153-
else Error_Code = UTM_ZONE_OVERRIDE_ERROR.toLong()
153+
else errorCode = UTM_ZONE_OVERRIDE_ERROR.toLong()
154154
}
155-
if (Error_Code == UTM_NO_ERROR.toLong()) {
156-
if (temp_zone >= 31) this.centralMeridian = (6 * temp_zone - 183) * PI / 180.0
157-
else this.centralMeridian = (6 * temp_zone + 177) * PI / 180.0
158-
this.zone = temp_zone.toInt()
159-
if (Latitude < 0) {
160-
False_Northing = 10000000.0
155+
if (errorCode == UTM_NO_ERROR.toLong()) {
156+
if (tempZone >= 31) this.centralMeridian = (6 * tempZone - 183) * PI / 180.0
157+
else this.centralMeridian = (6 * tempZone + 177) * PI / 180.0
158+
this.zone = tempZone.toInt()
159+
if (latitude < 0) {
160+
falseNorthing = 10000000.0
161161
this.hemisphere = AVKey.SOUTH
162162
} else this.hemisphere = AVKey.NORTH
163163

164164
try {
165165
val TM = fromLatLon(
166-
Angle.fromRadians(Latitude), Angle.fromRadians(Longitude),
167-
this.UTM_a, this.UTM_f, Angle.fromRadians(Origin_Latitude),
168-
Angle.fromRadians(this.centralMeridian), False_Easting, False_Northing, Scale
166+
Angle.fromRadians(latitude), Angle.fromRadians(lon),
167+
this.UTM_a, this.UTM_f, Angle.fromRadians(originLatitude),
168+
Angle.fromRadians(this.centralMeridian), falseEasting, falseNorthing, scale
169169
)
170170
this.easting = TM.easting
171171
this.northing = TM.northing
172172

173-
if ((this.easting < MIN_EASTING) || (this.easting > MAX_EASTING)) Error_Code =
173+
if ((this.easting < MIN_EASTING) || (this.easting > MAX_EASTING)) errorCode =
174174
UTM_EASTING_ERROR.toLong()
175-
if ((this.northing < MIN_NORTHING) || (this.northing > MAX_NORTHING)) Error_Code =
176-
Error_Code or UTM_NORTHING_ERROR.toLong()
175+
if ((this.northing < MIN_NORTHING) || (this.northing > MAX_NORTHING)) errorCode =
176+
errorCode or UTM_NORTHING_ERROR.toLong()
177177
} catch (e: Exception) {
178-
Error_Code = UTM_TM_ERROR.toLong()
178+
errorCode = UTM_TM_ERROR.toLong()
179179
}
180180
}
181181
}
182-
return (Error_Code)
182+
return (errorCode)
183183
}
184184

185185
/**

0 commit comments

Comments
 (0)