Skip to content

Commit a11a7a9

Browse files
Merge pull request #98 from OpenSmock/dev-pla
Change tile loading thread priority.
2 parents 256e05a + c3c71a1 commit a11a7a9

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

src/GeoView/GeoViewLocalDirectoryTilesProvider.class.st

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Class {
22
#name : #GeoViewLocalDirectoryTilesProvider,
33
#superclass : #GeoViewTilesProvider,
44
#instVars : [
5-
'tileDirectory'
5+
'tileDirectory',
6+
'imageType'
67
],
78
#category : #'GeoView-Map'
89
}
@@ -13,10 +14,16 @@ GeoViewLocalDirectoryTilesProvider class >> defaultDirectory [
1314
^ FileLocator imageDirectory / 'map' / 'r'
1415
]
1516

16-
{ #category : #initialization }
17-
GeoViewLocalDirectoryTilesProvider >> initialize [
18-
19-
super initialize.
17+
{ #category : #accessing }
18+
GeoViewLocalDirectoryTilesProvider >> imageType [
19+
20+
^ imageType
21+
]
22+
23+
{ #category : #accessing }
24+
GeoViewLocalDirectoryTilesProvider >> imageType: anObject [
25+
26+
imageType := anObject
2027
]
2128

2229
{ #category : #accessing }
@@ -35,13 +42,21 @@ GeoViewLocalDirectoryTilesProvider >> tileDirectory: anObject [
3542
{ #category : #request }
3643
GeoViewLocalDirectoryTilesProvider >> tileFilenameFor: aZoomLevel x: anXCoordinate y: anYCoordinate [
3744

38-
| filename |
45+
| filename types |
3946
filename := self tileDirectory asFileReference.
4047
filename exists ifFalse: [ ^ nil ].
4148

4249
filename := filename / aZoomLevel asString.
4350
filename := filename / anXCoordinate asString.
44-
filename := filename / (anYCoordinate asString , '.png').
51+
filename := filename / anYCoordinate asString.
52+
53+
imageType ifNil:[
54+
"trying to find the type of the image"
55+
types := #( 'jpg' 'png' ).
56+
imageType := types detect:[ :e | (filename , (e asString)) exists ] ifNone:[ ^ nil ].
57+
].
58+
59+
filename := filename , imageType asString.
4560

4661
^ filename
4762
]

src/GeoView/GeoViewMapTilesLayer.class.st

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,8 @@ GeoViewMapTilesLayer >> loadAndRenderTiles: aListTilesXY on: aSurface offset: an
583583
self dictTilesByLevel at: aLevel put: vMapServerTilesCopy.
584584
vMapServerTilesCopy := vMapServerTilesCopy copy.
585585

586-
self updateMapBackground
586+
self updateMapBackground.
587+
Processor yield.
587588

588589
] on:[ Exception ] do:[:ex |
589590
Transcript show: '[GeoView] Error on Tiles loading :'; show: ex printString; cr.
@@ -817,7 +818,7 @@ GeoViewMapTilesLayer >> restartMapBuilding [
817818
self stopTilesWorker.
818819

819820
self loadingTilesWorker: ([ self doLoadingTilesThread ]
820-
forkAt: Processor userSchedulingPriority named: '[GeoView] Map Tiles loading')
821+
forkAt: Processor userBackgroundPriority named: '[GeoView] Map Tiles loading')
821822
]
822823

823824
{ #category : #computing }
@@ -953,14 +954,14 @@ GeoViewMapTilesLayer >> updateModel: aContext [
953954

954955
currentGraphicProjection := self graphicProjection copy.
955956

957+
aContext isProjectionChanges ifFalse:[ ^ self ].
958+
self graphicProjection ifNil: [ ^ self ].
959+
956960
(aContext isExtentChanged or:[ aContext isScaleChanged ]) ifTrue:[
957961
self initSurfaceMap:
958962
currentGraphicProjection extentInPixels + (self mapOffcenter negated).
959963
self updateMapBackground.
960964
].
961-
962-
aContext isProjectionChanges ifFalse:[ ^ self ].
963-
self graphicProjection ifNil: [ ^ self ].
964965

965966
self previousCenter ifNil:[self previousCenter: currentGraphicProjection cartesianCenter copy].
966967
aContext isCenterChanged ifTrue:[

0 commit comments

Comments
 (0)