Skip to content

Commit 8ee3b23

Browse files
committed
address review comments
1 parent 4cd2d28 commit 8ee3b23

5 files changed

Lines changed: 193 additions & 53 deletions

src/GeoView-Tests/GeoViewMercatorProjectionTest.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ GeoViewMercatorProjectionTest >> testGeodesicCrossesValidDomainFromTo [
3535
self deny: (projection
3636
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
3737
to:
38-
(AbsoluteCoordinates latitudeInDegrees: 84 longitudeInDegrees: 180)).
38+
(AbsoluteCoordinates latitudeInDegrees: (projection latitudeMax) longitudeInDegrees: 180)).
3939

4040
self deny: (projection
4141
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
4242
to:
43-
(AbsoluteCoordinates latitudeInDegrees: -80 longitudeInDegrees: 180)).
43+
(AbsoluteCoordinates latitudeInDegrees: (projection latitudeMin) longitudeInDegrees: 180)).
4444

4545
self deny: (projection
4646
geodesicCrossesValidDomainFrom: (AbsoluteCoordinates latitudeInDegrees: 5.08 longitudeInDegrees: -19.01)

src/GeoView-Tests/GeoViewUTMProjectionTest.class.st

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,55 @@ GeoViewUTMProjectionTest >> testEquatorCentralMeridian [
6363
self assert: (result yInMeters roundTo: 0.1) equals: 0
6464
]
6565

66+
{ #category : #tests }
67+
GeoViewUTMProjectionTest >> testGeodesicCrossesValidDomainFromTo [
68+
69+
self deny: (projection
70+
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
71+
to:
72+
(AbsoluteCoordinates latitudeInDegrees: 45 longitudeInDegrees: 100)).
73+
74+
self deny: (projection
75+
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
76+
to:
77+
(AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0)).
78+
79+
self deny: (projection
80+
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
81+
to:
82+
(AbsoluteCoordinates latitudeInDegrees: (projection latitudeMax) longitudeInDegrees: 180)).
83+
84+
self deny: (projection
85+
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
86+
to:
87+
(AbsoluteCoordinates latitudeInDegrees: (projection latitudeMin) longitudeInDegrees: 180)).
88+
89+
self deny: (projection
90+
geodesicCrossesValidDomainFrom: (AbsoluteCoordinates latitudeInDegrees: 5.08 longitudeInDegrees: -19.01)
91+
to:
92+
(AbsoluteCoordinates latitudeInDegrees: 5.08 longitudeInDegrees: -19.00)).
93+
94+
"projection limits"
95+
self assert: (projection
96+
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
97+
to:
98+
(AbsoluteCoordinates latitudeInDegrees: 90 longitudeInDegrees: 100)).
99+
100+
self assert: (projection
101+
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
102+
to:
103+
(AbsoluteCoordinates latitudeInDegrees: -90 longitudeInDegrees: 100)).
104+
]
105+
106+
{ #category : #tests }
107+
GeoViewUTMProjectionTest >> testGeodesicCrossesZoneFromTo [
108+
109+
self assert: (projection
110+
geodesicCrossesZoneFrom: AbsoluteCoordinates zero
111+
to:
112+
(AbsoluteCoordinates latitudeInDegrees: 45 longitudeInDegrees: 100))
113+
]
114+
66115
{ #category : #'tests-accessing' }
67116
GeoViewUTMProjectionTest >> testHighLatitude [
68117

@@ -77,6 +126,29 @@ GeoViewUTMProjectionTest >> testHighLatitude [
77126
self assert: result yInMeters isNumber
78127
]
79128

129+
{ #category : #tests }
130+
GeoViewUTMProjectionTest >> testIsAbsoluteCoordinatesOutsideProjectionLimit [
131+
132+
self deny: (projection isAbsoluteCoordinatesOutsideProjectionLimit:
133+
AbsoluteCoordinates zero).
134+
135+
self deny: (projection isAbsoluteCoordinatesOutsideProjectionLimit:
136+
AbsoluteCoordinates frBrest).
137+
138+
"out"
139+
self assert:
140+
(projection isAbsoluteCoordinatesOutsideProjectionLimit:
141+
AbsoluteCoordinates new).
142+
143+
self assert:
144+
(projection isAbsoluteCoordinatesOutsideProjectionLimit:
145+
(AbsoluteCoordinates latitudeInDegrees: -90 longitudeInDegrees: 0)).
146+
147+
self assert:
148+
(projection isAbsoluteCoordinatesOutsideProjectionLimit:
149+
(AbsoluteCoordinates latitudeInDegrees: 90 longitudeInDegrees: 0))
150+
]
151+
80152
{ #category : #tests }
81153
GeoViewUTMProjectionTest >> testIsNorthernHemisphere [
82154

@@ -185,6 +257,43 @@ GeoViewUTMProjectionTest >> testReverseProj [
185257
self assert: lonDiff < 0.0001
186258
]
187259

260+
{ #category : #'tests-accessing' }
261+
GeoViewUTMProjectionTest >> testSideOfAbsoluteCoordinates [
262+
263+
self
264+
assert:
265+
(projection sideOfAbsoluteCoordinates: AbsoluteCoordinates zero)
266+
equals: GeoViewMapProjectionSide insideUTMZone.
267+
268+
self
269+
assert:
270+
(projection sideOfAbsoluteCoordinates: (AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: -1))
271+
equals: GeoViewMapProjectionSide leftOfUTMZone.
272+
273+
self
274+
assert:
275+
(projection sideOfAbsoluteCoordinates: (AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 20))
276+
equals: GeoViewMapProjectionSide rightOfUTMZone.
277+
278+
"limits"
279+
self
280+
assert:
281+
(projection sideOfAbsoluteCoordinates: (AbsoluteCoordinates latitudeInDegrees: 90 longitudeInDegrees: 0))
282+
equals: GeoViewMapProjectionSide outsideLatitudeLimitTop.
283+
284+
self
285+
assert:
286+
(projection sideOfAbsoluteCoordinates: (AbsoluteCoordinates latitudeInDegrees: -90 longitudeInDegrees: 0))
287+
equals: GeoViewMapProjectionSide outsideLatitudeLimitBottom.
288+
289+
"out"
290+
self
291+
assert:
292+
(projection sideOfAbsoluteCoordinates: AbsoluteCoordinates new)
293+
equals: GeoViewMapProjectionSide outOfProjection
294+
.
295+
]
296+
188297
{ #category : #'tests-accessing' }
189298
GeoViewUTMProjectionTest >> testSouthernHemisphere [
190299

src/GeoView-Tests/GeoViewWebMercatorProjectionTest.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ GeoViewWebMercatorProjectionTest >> testGeodesicCrossesValidDomainFromTo [
3535
self deny: (projection
3636
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
3737
to:
38-
(AbsoluteCoordinates latitudeInDegrees: 85.06 longitudeInDegrees: 180)).
38+
(AbsoluteCoordinates latitudeInDegrees: (projection latitudeMax) longitudeInDegrees: 180)).
3939

4040
self deny: (projection
4141
geodesicCrossesValidDomainFrom: AbsoluteCoordinates zero
4242
to:
43-
(AbsoluteCoordinates latitudeInDegrees: -85.06 longitudeInDegrees: 180)).
43+
(AbsoluteCoordinates latitudeInDegrees: (projection latitudeMin) longitudeInDegrees: 180)).
4444

4545
"projection limits"
4646
self assert: (projection

src/GeoView/GeoViewMapTilesLayer.class.st

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"
2+
I am a provisional implementation of a map tiles layer.
3+
I provide basic functionality for displaying tiled map data, but my current implementation has known limitations and will require a complete redesign in a future iteration.
4+
This is a temporary solution - use with the understanding that the API and internal structure will change significantly in future versions.
5+
"
16
Class {
27
#name : #GeoViewMapTilesLayer,
38
#superclass : #AbstractGeoViewBasicLayer,
@@ -100,26 +105,24 @@ GeoViewMapTilesLayer >> clip: num min: min max: max [
100105
{ #category : #'loading and updating' }
101106
GeoViewMapTilesLayer >> computeGraphicBoundsForTile: aGeoFormTile level: aLevel [
102107

103-
| centerPixel vMapTileCenter diffXY diffPixel origin corner graphicBounds centerGeoPoint|
104-
105-
aGeoFormTile isNoPicture ifTrue:[
106-
centerPixel := self getCenterInPixel.
107-
centerGeoPoint := self getCenterInGeoPoint.
108-
vMapTileCenter := self getTileXYFromGeoPoint: centerGeoPoint level: aLevel.
109-
diffXY := aGeoFormTile tileXY - vMapTileCenter.
110-
diffPixel := diffXY * (self defaultTileSize asPoint).
111-
origin := (centerPixel) + diffPixel.
112-
corner := origin + (self defaultTileSize asPoint).
113-
] ifFalse:[
114-
origin := self getGraphicPositionFromGeoPosition: aGeoFormTile geoBounds origin.
115-
corner := self getGraphicPositionFromGeoPosition: aGeoFormTile geoBounds corner.
116-
].
108+
| centerPixel vMapTileCenter diffXY diffPixel origin corner graphicBounds centerGeoPoint |
109+
aGeoFormTile isNoPicture
110+
ifTrue: [
111+
centerPixel := self getCenterInPixel.
112+
centerGeoPoint := self getCenterInGeoPoint.
113+
vMapTileCenter := self getTileXYFromGeoPoint: centerGeoPoint level: aLevel.
114+
diffXY := aGeoFormTile tileXY - vMapTileCenter.
115+
diffPixel := diffXY * self defaultTileSize asPoint.
116+
origin := centerPixel + diffPixel.
117+
corner := origin + self defaultTileSize asPoint ]
118+
ifFalse: [
119+
origin := self getGraphicPositionFromGeoPosition: aGeoFormTile geoBounds origin.
120+
corner := self getGraphicPositionFromGeoPosition: aGeoFormTile geoBounds corner ].
117121

118-
"origin and corner can be nil is case of out of projection"
119-
(origin isNil or:[corner isNil]) ifFalse:[
120-
graphicBounds := origin corner: corner.
121-
aGeoFormTile graphicBounds: graphicBounds
122-
]
122+
(origin isNil or: [ corner isNil ]) ifTrue: [ ^ self ].
123+
124+
graphicBounds := origin corner: corner.
125+
aGeoFormTile graphicBounds: graphicBounds
123126
]
124127

125128
{ #category : #'API -- tiles' }
@@ -150,7 +153,7 @@ GeoViewMapTilesLayer >> doLoadingTilesThread [
150153
self surfaceMap scale: 1@1.
151154

152155
centerGeoPoint := self getCenterInGeoPoint.
153-
level := self tileZLevel. "(self getTilesLevelForCurrentResolution) key."
156+
level := self tileZLevel.
154157

155158
tilesXY := self getTilesXYFor: centerGeoPoint level: level.
156159
tilesXYBuffer := self getTilesXYForBuffer: centerGeoPoint level: level.
@@ -912,7 +915,7 @@ GeoViewMapTilesLayer >> tileSize: anObject [
912915
tileSize := anObject
913916
]
914917

915-
{ #category : #level }
918+
{ #category : #accessing }
916919
GeoViewMapTilesLayer >> tileZLevel [
917920

918921
tileZLevel ifNil: [
@@ -921,7 +924,7 @@ GeoViewMapTilesLayer >> tileZLevel [
921924
^ tileZLevel
922925
]
923926

924-
{ #category : #level }
927+
{ #category : #accessing }
925928
GeoViewMapTilesLayer >> tileZLevel: anObject [
926929

927930
tileZLevel := anObject

src/GeoView/GeoViewUTMProjection.class.st

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,37 @@ GeoViewUTMProjection >> falseNorthingInMeters [
124124
{ #category : #testing }
125125
GeoViewUTMProjection >> 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 }
202228
GeoViewUTMProjection >> 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

Comments
 (0)