@@ -124,22 +124,37 @@ GeoViewUTMProjection >> falseNorthingInMeters [
124124{ #category : #testing }
125125GeoViewUTMProjection >> geodesicCrossesValidDomainFrom: aFromAbsoluteCoordinates to: aToAbsoluteCoordinates [
126126 " Check if geodesic crosses zone boundary or latitude limit"
127-
128- | fromZone toZone lat1 lat2 |
129- (aFromAbsoluteCoordinates isValid not or : [aToAbsoluteCoordinates isValid not ])
130- ifTrue: [ ^ true ].
131-
132- fromZone := self class zoneNumberFor: aFromAbsoluteCoordinates longitudeInDegrees.
133- toZone := self class zoneNumberFor: aToAbsoluteCoordinates longitudeInDegrees.
134-
135- " Check if crosses zone boundary"
136- fromZone ~= toZone ifTrue: [ ^ true ].
137-
127+
128+ | lat1 lat2 crossesLatCut |
129+ (aFromAbsoluteCoordinates isValid not or : [
130+ aToAbsoluteCoordinates isValid not ]) ifTrue: [ ^ true ].
131+
138132 " Check latitude limits"
139- lat1 := aFromAbsoluteCoordinates latitudeInDegrees abs.
140- lat2 := aToAbsoluteCoordinates latitudeInDegrees abs.
141-
142- ^ (lat1 > 84 or : [ lat2 > 84 ])
133+ lat1 := aFromAbsoluteCoordinates latitudeInDegrees.
134+ lat2 := aToAbsoluteCoordinates latitudeInDegrees.
135+ crossesLatCut := (lat1 < self latitudeMin or : [
136+ lat1 > self latitudeMax ]) or : [
137+ lat2 < self latitudeMin or : [
138+ lat2 > self latitudeMax ] ].
139+
140+ ^ crossesLatCut
141+ ]
142+
143+ { #category : #testing }
144+ GeoViewUTMProjection >> geodesicCrossesZoneFrom: aFromAbsoluteCoordinates to: aToAbsoluteCoordinates [
145+ " Check if geodesic crosses zone boundary"
146+
147+ | fromZone toZone |
148+ (aFromAbsoluteCoordinates isValid not or : [
149+ aToAbsoluteCoordinates isValid not ]) ifTrue: [ ^ true ].
150+
151+ fromZone := self class zoneNumberFor:
152+ aFromAbsoluteCoordinates longitudeInDegrees.
153+ toZone := self class zoneNumberFor:
154+ aToAbsoluteCoordinates longitudeInDegrees.
155+
156+ " Check if crosses zone boundary"
157+ ^ fromZone ~= toZone
143158]
144159
145160{ #category : #initialization }
@@ -166,11 +181,8 @@ GeoViewUTMProjection >> isAbsoluteCoordinatesOutsideProjectionLimit: anAbsoluteC
166181
167182 | lat |
168183 anAbsoluteCoordinates isValid ifFalse: [ ^ true ].
169-
170- lat := anAbsoluteCoordinates latitudeInDegrees abs.
171- lat > 84 ifTrue: [ ^ true ].
172-
173- ^ false
184+ lat := anAbsoluteCoordinates latitudeInDegrees.
185+ ^ lat < self latitudeMin or : [ lat > self latitudeMax ]
174186]
175187
176188{ #category : #accessing }
@@ -198,6 +210,20 @@ GeoViewUTMProjection >> key [
198210 ^ #GeoViewUTMProjection
199211]
200212
213+ { #category : #accessing }
214+ GeoViewUTMProjection >> latitudeMax [
215+ " UTM coordinates between 80°S and 84°N"
216+
217+ ^ 84
218+ ]
219+
220+ { #category : #accessing }
221+ GeoViewUTMProjection >> latitudeMin [
222+ " UTM coordinates between 80°S and 84°N"
223+
224+ ^ - 80
225+ ]
226+
201227{ #category : #private }
202228GeoViewUTMProjection >> meridianArc: aLatitudeInRadians [
203229 " Calculate meridian arc length"
@@ -321,20 +347,22 @@ GeoViewUTMProjection >> sideOfAbsoluteCoordinates: anAbsolutePosition [
321347 " Return the position relative to this UTM zone"
322348
323349 | coordZone lat |
324- anAbsolutePosition isValid ifFalse: [ ^ GeoViewMapProjectionSide outOfProjection ].
350+ anAbsolutePosition isValid ifFalse: [
351+ ^ GeoViewMapProjectionSide outOfProjection ].
325352
326353 lat := anAbsolutePosition latitudeInDegrees.
327354
328355 " Check latitude limits"
329- lat abs > 84 ifTrue: [
330- ^ lat > 0
331- ifTrue: [ GeoViewMapProjectionSide outsideLatitudeLimitTop ]
332- ifFalse: [ GeoViewMapProjectionSide outsideLatitudeLimitBottom ] ].
356+ lat > self latitudeMax ifTrue: [
357+ ^ GeoViewMapProjectionSide outsideLatitudeLimitTop ].
358+ lat < self latitudeMin ifTrue: [
359+ ^ GeoViewMapProjectionSide outsideLatitudeLimitBottom ].
333360
334361 " Check hemisphere"
335362 (lat >= 0 and : [ self isNorthernHemisphere not ]) ifTrue: [
336363 ^ GeoViewMapProjectionSide wrongUTMHemisphere ].
337- (lat < 0 and : [ self isNorthernHemisphere ]) ifTrue: [ ^ GeoViewMapProjectionSide wrongUTMHemisphere ].
364+ (lat < 0 and : [ self isNorthernHemisphere ]) ifTrue: [
365+ ^ GeoViewMapProjectionSide wrongUTMHemisphere ].
338366
339367 " Check zone"
340368 coordZone := self class zoneNumberFor:
@@ -344,7 +372,7 @@ GeoViewUTMProjection >> sideOfAbsoluteCoordinates: anAbsolutePosition [
344372 ifTrue: [ GeoViewMapProjectionSide leftOfUTMZone ]
345373 ifFalse: [ GeoViewMapProjectionSide rightOfUTMZone ] ].
346374
347- ^ GeoViewMapProjectionSide insideUTMZone
375+ ^ GeoViewMapProjectionSide insideUTMZone
348376]
349377
350378{ #category : #accessing }
0 commit comments