Timestamp in custom tile source

9 views
Skip to first unread message

pistolingo

unread,
May 20, 2019, 12:35:55 PM5/20/19
to Osmand
Hi everyone,

so I'm currently trying to set up a custom tile source that requires a timestamp in the tile url. Manually changing that timestamp works but since changes happen in the minute range it's not really a feasible solution.
I read up on beanshell and figured it shouldn't be too hard but the problem I run into is that any function that would be able to generate a timestamp fails. I also played around with some imports to no avail. For some reason it seems nothing is known about "higher level" java functions.
Logcat when using System.currentTimeMillis():
2019-05-20 18:22:53.738 19761-19782/? E/net.osmand: TileSourceManager Sourced file: inline evaluation of: ``getTileUrl(6,35,26);'' : Typed variable declaration : Attempt to resolve method: currentTimeMillis() on undefined variable or class name: System
   
Sourced file: inline evaluation of: ``getTileUrl(6,35,26);'' : Typed variable declaration : Attempt to resolve method: currentTimeMillis() on undefined variable or class name: System : at Line: 1 : in file: inline evaluation of: ``String getTileUrl(int z, int x, int y) {int time= (int)(System.currentTimeMillis . . . '' : System .currentTimeMillis ( )


The .metainfo is currently looking something like this:
[rule]
beanshell
[url_template]
String getTileUrl(int z, int x, int y) {int time = System.currentTimeMillis()/1000; time = time-time %600; return "https://my.tile.cache/"+time+"/"+z+"/"+x+"/"+y+"/tile.png";}
[ext]
png
[min_zoom]
1
[max_zoom]
18
[tile_size]
256
[img_density]
16
[avg_img_size]
18000

So I've run out of ideas what to try and started wondering if it is at all possible what I'm trying to do.
Any help or definitive answer would be appreciated.

Thanks!
Reply all
Reply to author
Forward
0 new messages