Re: kaMap - setTile function - uses openstreetmap servers.

View: New views
2 Messages — Rating Filter:   Alert me  

Re: kaMap - setTile function - uses openstreetmap servers.

by Joe Franklin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


very cool.  has anyone modified tile.php so it can accept x/y/z parameters instead of the top/left/scale parameters?  then tile.php could be used instead of TileCache which is written in Python instead of PHP.

joe



--- On Mon, 5/25/09, Ionut Muntean <ionut@...> wrote:

> From: Ionut Muntean <ionut@...>
> Subject: [ka-Map-users] kaMap - setTile function - uses openstreetmap servers.
> To: "ka-map-users" <ka-map-users@...>
> Date: Monday, May 25, 2009, 6:52 AM
> kaMap - setTile function - uses
> openstreetmap servers.
>
> File that replaces init.php. Paste the code below in a file
> on your
> server and load it at run time instead of init.php.
>
> /*init*/
> aszScales = new
> Array('110936068.18103503','55468034.09051751','27734017.045258757',
> '13867008.522629378','6933504.261313272','3466752.130658053',
> '1733376.0653290264','866688.0326645132','433344.0163322566',
> '216672.008164711','108336.00408377283','54168.002041886415',
> '27084.001020943208','13542.000510471604','6771.000253818478',
> '3385.5001283265624','1692.7500655806048');
> var mResolutions = new Array('156543.0339', '78271.51695',
>
> '39135.758475', '19567.8792375', '9783.93961875',
> '4891.969809375',
> '2445.984904687',
>                
>             '1222.992452344',
> '611.496226172',
> '305.748113086', '152.874056543', '76.437028271',
> '38.218514136',
> '19.109257068',
>                
>             '9.554628534',
> '4.777314267', '2.388657133',
> '1.194328567', '0.597164284');
> var map = new
> _map({name:'Terra',title:'World',currentScale:2,units:3,resolution:72,version:'3',scales:aszScales,
>
> resolutions:mResolutions});
> map.setDefaultExtents(-20037508.34, -200037508.34,
> 200037508.34,
> 200037508.34);
> map.setBackgroundColor('rgb(244,244,234)');
> map.addLayer(new _layer( {
> name:'Terra',visible:true,opacity:100,imageformat:'png',queryable:false,tileSource:'auto',redrawInterval:-1,refreshInterval:-1,scales:
>
> new
> Array('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1')}));
> this.addMap( map );
> this.tileWidth=256;
> this.tileHeight=256;
> this.server = 'http://xxx.xxx.xxx/';
> this.tileURL = 'http://a.tile.osm.dmtech.ro/tiles/';
> this.cacheURL = 'http://localcache.xxx.xxx/tiles/';
> this.selectMap('Terra');
>
>
> Replace setTile with the function below.
>
> _layer.prototype.setTile = function(img) {
>    var tforce = _settings.alwaysForceDraw;
>    if (arguments.length == 2)
>        tforce = true;
>    var mercExtents = new
> Array('-20037508.34', '20037508.34');
>    var zIdx = (this._map.currentScale + 2);
> // osm zooms are from 0 to
> 18. azScales contains only calculated scales from 2 to 18
> ...
>    var res = this._map.resolutions[zIdx];
>    var km = this._map.kaMap;
>    var left = km.cellSize *
> (safeParseInt(img.style.left) + km.xOrigin);
>    var top = -1 * km.cellSize *
> (safeParseInt(img.style.top) + km.yOrigin);
>    var right = left + km.cellSize *
> km.tileWidth;
>    var bottom = top - km.cellSize *
> km.tileHeight;
>    if (left < mercExtents[0] || left >
> mercExtents[2] || top <
> mercExtents[0] || top > mercExtents[1]) return false;
>    var limit = Math.pow(2, zIdx);
>    var x = Math.round((left -
> mercExtents[0]) / (res * km.tileWidth));
>    var y = Math.round((mercExtents[1] - top)
> / (res * km.tileHeight));
>    if (y < 0 || y >= limit) return
> false;
>    x = ((x % limit) + limit) % limit;
>    if (tforce) {
>       var src = this._map.kaMap.tileURL +
> zIdx + '/' + x + '/' + y + '.png';
>    } else {
>       var src = this._map.kaMap.cacheURL +
> zIdx + '/' + x + '/' + y +
> '.png';
>    }
>    if (img.src != src) {
>        img.style.visibility =
> 'hidden';
>        img.src = src;
>    }
> };
>
>
>
> Have fun!
> Ionut Muntean
>
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users@...
> http://lists.maptools.org/mailman/listinfo/ka-map-users
>


     
_______________________________________________
ka-Map-users mailing list
ka-Map-users@...
http://lists.maptools.org/mailman/listinfo/ka-map-users

Re: kaMap - setTile function - uses openstreetmap servers.

by Ionut Muntean :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

nope. at least i am not aware of any modified tile.php. life and need put me to do this hack on setTile. the big challange was (for me) to put azScales to match kaMap.

kaMap display engine is fast and simple. nothing fancy, but very functional. this is why i will use it as a starting point for displaying tiles in my projects. so, if i can hack into the js code of kaMap, why use tile.php? ... or openlayers ...

this could become a layer such as wmslayer ... maybe sometime when i have time or maybe someone else could do this ;)

ionut

Joe Franklin wrote:
very cool.  has anyone modified tile.php so it can accept x/y/z parameters instead of the top/left/scale parameters?  then tile.php could be used instead of TileCache which is written in Python instead of PHP.

joe



--- On Mon, 5/25/09, Ionut Muntean ionut@... wrote:

  
From: Ionut Muntean ionut@...
Subject: [ka-Map-users] kaMap - setTile function - uses openstreetmap servers.
To: "ka-map-users" ka-map-users@...
Date: Monday, May 25, 2009, 6:52 AM
kaMap - setTile function - uses
openstreetmap servers.

File that replaces init.php. Paste the code below in a file
on your 
server and load it at run time instead of init.php.

/*init*/
aszScales = new 
Array('110936068.18103503','55468034.09051751','27734017.045258757',
'13867008.522629378','6933504.261313272','3466752.130658053',
'1733376.0653290264','866688.0326645132','433344.0163322566',
'216672.008164711','108336.00408377283','54168.002041886415',
'27084.001020943208','13542.000510471604','6771.000253818478',
'3385.5001283265624','1692.7500655806048');
var mResolutions = new Array('156543.0339', '78271.51695',

'39135.758475', '19567.8792375', '9783.93961875',
'4891.969809375', 
'2445.984904687',
               
            '1222.992452344',
'611.496226172', 
'305.748113086', '152.874056543', '76.437028271',
'38.218514136', 
'19.109257068',
               
            '9.554628534',
'4.777314267', '2.388657133', 
'1.194328567', '0.597164284');
var map = new 
_map({name:'Terra',title:'World',currentScale:2,units:3,resolution:72,version:'3',scales:aszScales,

resolutions:mResolutions});
map.setDefaultExtents(-20037508.34, -200037508.34,
200037508.34, 
200037508.34);
map.setBackgroundColor('rgb(244,244,234)');
map.addLayer(new _layer( { 
name:'Terra',visible:true,opacity:100,imageformat:'png',queryable:false,tileSource:'auto',redrawInterval:-1,refreshInterval:-1,scales:

new 
Array('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1')}));
this.addMap( map );
this.tileWidth=256;
this.tileHeight=256;
this.server = 'http://xxx.xxx.xxx/';
this.tileURL = 'http://a.tile.osm.dmtech.ro/tiles/';
this.cacheURL = 'http://localcache.xxx.xxx/tiles/';
this.selectMap('Terra');


Replace setTile with the function below.

_layer.prototype.setTile = function(img) {
   var tforce = _settings.alwaysForceDraw;
   if (arguments.length == 2)
       tforce = true;
   var mercExtents = new
Array('-20037508.34', '20037508.34');
   var zIdx = (this._map.currentScale + 2);
// osm zooms are from 0 to 
18. azScales contains only calculated scales from 2 to 18
...
   var res = this._map.resolutions[zIdx];
   var km = this._map.kaMap;
   var left = km.cellSize *
(safeParseInt(img.style.left) + km.xOrigin);
   var top = -1 * km.cellSize *
(safeParseInt(img.style.top) + km.yOrigin);
   var right = left + km.cellSize *
km.tileWidth;
   var bottom = top - km.cellSize *
km.tileHeight;
   if (left < mercExtents[0] || left >
mercExtents[2] || top < 
mercExtents[0] || top > mercExtents[1]) return false;
   var limit = Math.pow(2, zIdx);
   var x = Math.round((left -
mercExtents[0]) / (res * km.tileWidth));
   var y = Math.round((mercExtents[1] - top)
/ (res * km.tileHeight));
   if (y < 0 || y >= limit) return
false;
   x = ((x % limit) + limit) % limit;
   if (tforce) {
      var src = this._map.kaMap.tileURL +
zIdx + '/' + x + '/' + y + '.png';
   } else {
      var src = this._map.kaMap.cacheURL +
zIdx + '/' + x + '/' + y + 
'.png';
   }
   if (img.src != src) {
       img.style.visibility =
'hidden';
       img.src = src;
   }
};



Have fun!
Ionut Muntean


_______________________________________________
ka-Map-users mailing list
ka-Map-users@...
http://lists.maptools.org/mailman/listinfo/ka-map-users

    


      

  


_______________________________________________
ka-Map-users mailing list
ka-Map-users@...
http://lists.maptools.org/mailman/listinfo/ka-map-users