Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 20 additions & 36 deletions src/GeoView/GeoViewGoogleTilesProvider.class.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Class {
#name : #GeoViewGoogleTilesProvider,
#superclass : #GeoViewTilesProvider,
#superclass : #GeoViewTilesProviderTMS,
#instVars : [
'serverUrl',
'tilesType'
],
#category : #'GeoView-Map'
Expand Down Expand Up @@ -35,37 +34,43 @@ GeoViewGoogleTilesProvider class >> primaryTileUrl [
{ #category : #'tiles type' }
GeoViewGoogleTilesProvider >> beHybridType [

tilesType := 'y'
tilesType := 'y'.
self updateUrl
]

{ #category : #'tiles type' }
GeoViewGoogleTilesProvider >> beRoadmapType [

tilesType := 'm'
tilesType := 'm'.
self updateUrl
]

{ #category : #'tiles type' }
GeoViewGoogleTilesProvider >> beRoadsOnlyType [

tilesType := 'h'
tilesType := 'h'.
self updateUrl
]

{ #category : #'tiles type' }
GeoViewGoogleTilesProvider >> beSatelliteType [

tilesType := 's'
tilesType := 's'.
self updateUrl
]

{ #category : #'tiles type' }
GeoViewGoogleTilesProvider >> beTerrainOnlyType [

tilesType := 't'
tilesType := 't'.
self updateUrl
]

{ #category : #'tiles type' }
GeoViewGoogleTilesProvider >> beTerrainType [

tilesType := 'p'
tilesType := 'p'.
self updateUrl
]

{ #category : #initialization }
Expand All @@ -79,34 +84,13 @@ GeoViewGoogleTilesProvider >> initialize [
]

{ #category : #accessing }
GeoViewGoogleTilesProvider >> serverUrl [

^ serverUrl ifNil: [ serverUrl := self class primaryTileUrl ]
]

{ #category : #accessing }
GeoViewGoogleTilesProvider >> serverUrl: anObject [

serverUrl := anObject
]

{ #category : #request }
GeoViewGoogleTilesProvider >> tileFilenameFor: aZoomLevel x: anXCoordinate y: anYCoordinate [

^ self serverUrl , '/lyrs=' , ( tilesType asString ) , '&x=' , anXCoordinate printString , '&y='
, anYCoordinate printString , '&z=' , aZoomLevel printString
]

{ #category : #request }
GeoViewGoogleTilesProvider >> tileFor: aZoomLevel x: anXCoordinate y: anYCoordinate [

| url |
url := self
tileFilenameFor: aZoomLevel
x: anXCoordinate
y: anYCoordinate.
GeoViewGoogleTilesProvider >> updateUrl [

| format |

format := '.png'.
(tilesType = 's' or:[tilesType = 'y' or:[tilesType = 't' or:[tilesType = 'p']]])
ifTrue: [ ^ ZnEasy getJpeg: url ]
ifFalse: [ ^ ZnEasy getPng: url ]
ifTrue: [ format := '.jpg' ].

self service url: self serverUrl, '?lyrs=', ( tilesType asString ), '&x={x}&y={y}&z={z}&ext=', format
]
38 changes: 7 additions & 31 deletions src/GeoView/GeoViewOpenStreetMapTilesProvider.class.st
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
Class {
#name : #GeoViewOpenStreetMapTilesProvider,
#superclass : #GeoViewTilesProvider,
#instVars : [
'serverUrl'
],
#superclass : #GeoViewTilesProviderTMS,
#category : #'GeoView-Map'
}

Expand All @@ -28,43 +25,22 @@ GeoViewOpenStreetMapTilesProvider class >> mirror2TileUrl [
{ #category : #constants }
GeoViewOpenStreetMapTilesProvider class >> primaryTileUrl [

"^ 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'"
^ 'https://a.tile.openstreetmap.org'

]

{ #category : #initialization }
GeoViewOpenStreetMapTilesProvider >> initialize [

super initialize.
self haveCopyrightNote: true.
self defaultCopyrightNote: self class attributionText
self defaultCopyrightNote: self class attributionText.
self updateUrl
]

{ #category : #accessing }
GeoViewOpenStreetMapTilesProvider >> serverUrl [
GeoViewOpenStreetMapTilesProvider >> updateUrl [

^ serverUrl ifNil: [ serverUrl := self class primaryTileUrl ]
]

{ #category : #accessing }
GeoViewOpenStreetMapTilesProvider >> serverUrl: anObject [

serverUrl := anObject
]

{ #category : #request }
GeoViewOpenStreetMapTilesProvider >> tileFilenameFor: aZoomLevel x: anXCoordinate y: anYCoordinate [

^ self serverUrl , '/' , aZoomLevel printString , '/'
, anXCoordinate printString , '/' , anYCoordinate printString
, '.png'
]

{ #category : #request }
GeoViewOpenStreetMapTilesProvider >> tileFor: aZoomLevel x: anXCoordinate y: anYCoordinate [

^ ZnEasy getPng:
(self
tileFilenameFor: aZoomLevel
x: anXCoordinate
y: anYCoordinate)
self service url: self serverUrl, '/{z}/{x}/{y}.png'
]
40 changes: 40 additions & 0 deletions src/GeoView/GeoViewTilesProviderTMS.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Class {
#name : #GeoViewTilesProviderTMS,
#superclass : #GeoViewTilesProvider,
#instVars : [
'service',
'serverUrl'
],
#category : #'GeoView-Map'
}

{ #category : #accessing }
GeoViewTilesProviderTMS >> serverUrl [

^ serverUrl ifNil: [ serverUrl := self class primaryTileUrl ]
]

{ #category : #accessing }
GeoViewTilesProviderTMS >> serverUrl: anObject [

serverUrl := anObject.
self updateUrl
]

{ #category : #accessing }
GeoViewTilesProviderTMS >> service [

^ service ifNil: [ service := PharoOWSTMS new ]
]

{ #category : #request }
GeoViewTilesProviderTMS >> tileFor: aZoomLevel x: anXCoordinate y: anYCoordinate [

^ self service tile: anXCoordinate y: anYCoordinate z: aZoomLevel
]

{ #category : #accessing }
GeoViewTilesProviderTMS >> updateUrl [

self subclassResponsibility
]