Skip to content
Merged
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 @@ -78,35 +83,14 @@ GeoViewGoogleTilesProvider >> initialize [
self beSatelliteType
]

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

^ 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.
| 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
]
5 changes: 3 additions & 2 deletions src/GeoView/GeoViewMapTilesLayer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,11 @@ GeoViewMapTilesLayer >> doLoadingTilesThread [
{ #category : #accessing }
GeoViewMapTilesLayer >> getCenterInGeoPoint [

| center centerGeoPoint |
| center centerGeoPoint coords |
center := currentGraphicProjection cartesianCenter.
centerGeoPoint := self mapProjection projCartToLatLon: center.
^ centerGeoPoint asLonLatDegreesPoint
coords := centerGeoPoint asLatLonDegreesPoint.
^ coords y @ coords x
]

{ #category : #accessing }
Expand Down
65 changes: 6 additions & 59 deletions src/GeoView/GeoViewOpenStreetMapTilesProvider.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
Class {
#name : #GeoViewOpenStreetMapTilesProvider,
#superclass : #GeoViewTilesProvider,
#instVars : [
'serverUrl',
'znClient'
],
#superclass : #GeoViewTilesProviderTMS,
#category : #'GeoView-Map'
}

Expand Down Expand Up @@ -36,62 +32,13 @@ GeoViewOpenStreetMapTilesProvider class >> primaryTileUrl [
GeoViewOpenStreetMapTilesProvider >> initialize [

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

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

znClient := ZnClient new.
znClient
loggingOff;
accept: ZnMimeType imagePng;
enforceHttpSuccess: true;
enforceAcceptContentType: true;
beOneShot
]

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

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

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

serverUrl := anObject
]
{ #category : #update }
GeoViewOpenStreetMapTilesProvider >> updateUrl [

{ #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 [

| url contents |
url := self
tileFilenameFor: aZoomLevel
x: anXCoordinate
y: anYCoordinate.
url ifNil: [ ^ nil ].

self znClient get: url.
contents := self znClient contents.
contents ifNil: [ ^ nil ].

^ ImageReadWriter formFromStream: contents readStream
]

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

^ znClient
self service url: self serverUrl, '/{z}/{x}/{y}.png'
]
6 changes: 0 additions & 6 deletions src/GeoView/GeoViewTilesProvider.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ GeoViewTilesProvider >> initialize [
self haveCopyrightNote: false
]

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

self subclassResponsibility
]

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

Expand Down
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 : #update }
GeoViewTilesProviderTMS >> updateUrl [

self subclassResponsibility
]