User:Thraxis Epsilon/map api

From Second Life Wiki
< User:Thraxis Epsilon
Revision as of 11:36, 25 January 2008 by Thraxis Epsilon (talk | contribs) (New page: == Purpose == To define a better Web Map API that follows pre-existing standards and allows for use without restrictions that the current implementation has. == Problems with the current...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Purpose

To define a better Web Map API that follows pre-existing standards and allows for use without restrictions that the current implementation has.

Problems with the current system

The current Web Map API has several issues. The first is the reliance on the Google API. This requires an API key and ties the map to a specific domain. Also the tile system designed for this purpose does not match the Second Life tile layout. The region "Da Boom" is at tile position 1000,1000 in the SL map. Yet the tile service identifies this tile as 1000,279.

Proposed Solution

The tile system should retain a one to one parity with the SL co-ordinate system. To do this using the TMS (Tile Map Service) Specification

I built a PHP translation layer to translate TMS calls to SL Map API calls:

<php> <? $temp1 = str_replace(".jpg", "", $_SERVER['PHP_SELF']); $temp1 = str_replace("/", "|", $temp1 ); $temp = explode("|",$temp1);

$zoom = 7 - $temp[3]; $factor = pow(2,$zoom-1); $y = (1280/$factor)-$temp[5] - 1;

if ($temp[2] == "overlay") { $layer = 1; } if ($temp[2] == "map") { $layer = 0; } header( 'Location: http://secondlife.com/apps/mapapi/grid/map_image/'.$temp[4].'-'.$y.'-'.$zoom.'-'.$layer.'.htm' ) ; ?> </php>

This translates calls in the following format: http://url.to.server/OpenLayers/tms.php/1.0.0/map/6/1000/1000.jpg To the SL Map Tile server format of: http://secondlife.com/apps/mapapi/grid/map_image/1000-279-1-0.htm

For testing this works rather well and the result, using the OpenLayers API can be seen at Example Map

NOTE: The example listed is also using a partial wrapper to translate SL Map API calls to OpenLayers