81
81
* tiles.rootDir=URL root directory of tiles
82
82
* # a local location to cache tiles, to reduce load on server.
83
83
* tiles.localCacheRootDir=/data/tiles/osmtiles
84
+ * # save cache when layer is done (true by default)
85
+ * tiles.saveCache=true
84
86
*
85
87
* # other properties are the same.
86
88
* tiles.fileExt=.png
@@ -161,9 +163,10 @@ public class MapTileLayer extends OMGraphicHandlerLayer implements MapTileReques
161
163
public final static String DATA_ATTRIBUTION_PROPERTY = "attribution" ;
162
164
163
165
/**
164
- * A property to disable tile factory reset on layer being removed.
166
+ * A property to save or destroy the tile factory cache when the layer is
167
+ * removed.
165
168
*/
166
- public final static String DISABLE_TILE_FACTORY_RESET = "disableTileFactoryReset " ;
169
+ public final static String SAVE_CACHE_PROPERTY = "saveCache " ;
167
170
/**
168
171
* The MapTileFactory that knows how to fetch image files and create
169
172
* OMRasters for them.
@@ -189,9 +192,9 @@ public class MapTileLayer extends OMGraphicHandlerLayer implements MapTileReques
189
192
protected String attribution = null ;
190
193
191
194
/**
192
- * Flag to disable tile factory reset on layer being removed .
195
+ * Flag to save tile factory cache when the layer is no longer used .
193
196
*/
194
- protected boolean disableTileFactoryReset = false ;
197
+ protected boolean saveCache = true ;
195
198
196
199
/**
197
200
* Rendering parameters for attribution string.
@@ -310,8 +313,7 @@ public void setProperties(String prefix, Properties props) {
310
313
311
314
setZoomLevel (PropUtils .intFromProperties (props , prefix + ZOOM_LEVEL_PROPERTY , zoomLevel ));
312
315
313
- disableTileFactoryReset = PropUtils .booleanFromProperties (props , prefix
314
- + DISABLE_TILE_FACTORY_RESET , disableTileFactoryReset );
316
+ saveCache = PropUtils .booleanFromProperties (props , prefix + SAVE_CACHE_PROPERTY , saveCache );
315
317
}
316
318
317
319
public Properties getProperties (Properties props ) {
@@ -328,7 +330,7 @@ public Properties getProperties(Properties props) {
328
330
props .put (prefix + INCREMENTAL_UPDATES_PROPERTY , Boolean .toString (incrementalUpdates ));
329
331
props .put (prefix + ZOOM_LEVEL_PROPERTY , Integer .toString (zoomLevel ));
330
332
props .put (prefix + DATA_ATTRIBUTION_PROPERTY , PropUtils .unnull (attribution ));
331
- props .put (prefix + DISABLE_TILE_FACTORY_RESET , Boolean .toString (disableTileFactoryReset ));
333
+ props .put (prefix + SAVE_CACHE_PROPERTY , Boolean .toString (saveCache ));
332
334
333
335
attributionAttributes .getProperties (props );
334
336
@@ -342,16 +344,16 @@ public Properties getPropertyInfo(Properties props) {
342
344
"Force zoom level for queries (-1 is no forcing)" , null );
343
345
PropUtils .setI18NPropertyInfo (i18n , props , this .getClass (), DATA_ATTRIBUTION_PROPERTY , "Attribution" ,
344
346
"Attribution for data source" , null );
345
- PropUtils .setI18NPropertyInfo (i18n , props , this .getClass (), DISABLE_TILE_FACTORY_RESET , "Disable Tile Factory Reset" , "Disable tile factory reset on layer remove" , null );
347
+ PropUtils .setI18NPropertyInfo (i18n , props , this .getClass (), SAVE_CACHE_PROPERTY , "Disable Tile Factory Reset" , "Disable tile factory reset on layer remove" , null );
346
348
if (tileFactory instanceof StandardMapTileFactory ) {
347
349
((StandardMapTileFactory ) tileFactory ).getPropertyInfo (props );
348
350
props .put (initPropertiesProperty , ((StandardMapTileFactory ) tileFactory ).getInitPropertiesOrder ()
349
351
+ " " + ZOOM_LEVEL_PROPERTY + " " + DATA_ATTRIBUTION_PROPERTY + " "
350
- + DISABLE_TILE_FACTORY_RESET );
352
+ + SAVE_CACHE_PROPERTY );
351
353
} else {
352
354
props .put (initPropertiesProperty , StandardMapTileFactory .ROOT_DIR_PROPERTY + " "
353
355
+ StandardMapTileFactory .FILE_EXT_PROPERTY + " " + ZOOM_LEVEL_PROPERTY + " "
354
- + DATA_ATTRIBUTION_PROPERTY + " " + DISABLE_TILE_FACTORY_RESET );
356
+ + DATA_ATTRIBUTION_PROPERTY + " " + SAVE_CACHE_PROPERTY );
355
357
}
356
358
357
359
return props ;
@@ -363,7 +365,7 @@ public Properties getPropertyInfo(Properties props) {
363
365
*/
364
366
public void removed (Container cont ) {
365
367
MapTileFactory tileFactory = getTileFactory ();
366
- if (tileFactory != null && !disableTileFactoryReset ) {
368
+ if (tileFactory != null && !saveCache ) {
367
369
tileFactory .reset ();
368
370
}
369
371
}
0 commit comments