diff --git a/src/GeoView/GeoViewGoogleTilesProvider.class.st b/src/GeoView/GeoViewGoogleTilesProvider.class.st index a14f845..4fc66b5 100644 --- a/src/GeoView/GeoViewGoogleTilesProvider.class.st +++ b/src/GeoView/GeoViewGoogleTilesProvider.class.st @@ -1,8 +1,7 @@ Class { #name : #GeoViewGoogleTilesProvider, - #superclass : #GeoViewTilesProvider, + #superclass : #GeoViewTilesProviderTMS, #instVars : [ - 'serverUrl', 'tilesType' ], #category : #'GeoView-Map' @@ -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 } @@ -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 ] diff --git a/src/GeoView/GeoViewMapTilesLayer.class.st b/src/GeoView/GeoViewMapTilesLayer.class.st index 20a9a0b..b5f851c 100644 --- a/src/GeoView/GeoViewMapTilesLayer.class.st +++ b/src/GeoView/GeoViewMapTilesLayer.class.st @@ -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 } diff --git a/src/GeoView/GeoViewOpenStreetMapTilesProvider.class.st b/src/GeoView/GeoViewOpenStreetMapTilesProvider.class.st index a37db3a..107edb0 100644 --- a/src/GeoView/GeoViewOpenStreetMapTilesProvider.class.st +++ b/src/GeoView/GeoViewOpenStreetMapTilesProvider.class.st @@ -1,10 +1,6 @@ Class { #name : #GeoViewOpenStreetMapTilesProvider, - #superclass : #GeoViewTilesProvider, - #instVars : [ - 'serverUrl', - 'znClient' - ], + #superclass : #GeoViewTilesProviderTMS, #category : #'GeoView-Map' } @@ -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' ] diff --git a/src/GeoView/GeoViewTilesProvider.class.st b/src/GeoView/GeoViewTilesProvider.class.st index 49506a8..f7ed707 100644 --- a/src/GeoView/GeoViewTilesProvider.class.st +++ b/src/GeoView/GeoViewTilesProvider.class.st @@ -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 [ diff --git a/src/GeoView/GeoViewTilesProviderTMS.class.st b/src/GeoView/GeoViewTilesProviderTMS.class.st new file mode 100644 index 0000000..90d24a9 --- /dev/null +++ b/src/GeoView/GeoViewTilesProviderTMS.class.st @@ -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 +]