Skip to content

Commit 3d1ae92

Browse files
Merge pull request #31 from ThalesGroup/dev-29
Fix issue 29 (cannot test) and 30
2 parents 59f1d45 + 1f07129 commit 3d1ae92

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/OWS-Tests/OWSTMSTest.class.st

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ OWSTMSTest >> testTile [
2222
tms url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'.
2323

2424
tile := tms tile: 0 y: 0 z: 0.
25-
2625
self assert: tile height equals: 256.
2726
self assert: tile width equals: 256
2827
]
28+
29+
{ #category : #tests }
30+
OWSTMSTest >> testTileNotExists [
31+
32+
| tile |
33+
tms url: 'https://tile.thisdomaindoesnotexist.org/{z}/{x}/{y}.png'.
34+
35+
tile := tms tile: 0 y: 0 z: 0.
36+
self assert: tile isNil
37+
]

src/OWS/OWSTMS.class.st

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ OWSTMS >> tile: aX y: aY z: aZ [
1515
tileUrl := tileUrl copyReplaceAll: '{y}' with: aY printString.
1616
tileUrl := tileUrl copyReplaceAll: '{z}' with: aZ printString.
1717

18-
result := ZnClient new
18+
result := [ ZnClient new
1919
url: tileUrl;
20-
get.
20+
get ] on: NameLookupFailure do:[ :ex |
21+
"Cannot reach the url, curently when there is no network, return nil"
22+
nil
23+
].
2124

22-
result isString ifTrue: [ (Error new messageText: result) signal ].
25+
result ifNil:[ ^ nil ].
26+
result isString ifTrue: [ ^ nil ].
2327

2428
^ Form fromBinaryStream: result readStream
2529
]

0 commit comments

Comments
 (0)