LamaUrbain / LamaServer

The API.
4 stars 0 forks source link

Server/client communication from map data #4

Closed LouisDuVerdier closed 9 years ago

LouisDuVerdier commented 9 years ago

Given the following terms:

Request from the client :

Request GET HTTP : http://adress.server.com/service?service=map&latitude=48.8534100&longitude=2.3488000&width=800&height=800&scale=0.01875

This request asks for all tiles in a range of 800x800px at a scale of 0.01875 (that means 1px = 0.01875 degree, and so that 800px = 15 degrees), with 48.8534100 for the latitude and 2.3488000 for the longitude of the center (Paris' coordinates). It is expected to get a given number of n tiles, depending on the fixed size of a tile (64 tiles if a tile's size is 100x100px, for this request).

JSON response from the server :

{
    "tiles": [
        {
            "latitude": 48.8534100, // latitude of the tile's center
            "longitude": 2.3488000, // longitude of the tile's center
            "scale": 0.01875, // tile's scale (should be the same as the scale given in the client's request)
            "pixmap": "http://adress.server.com/images/00011283840.png" // static URI of the image
        },
        {
            "latitude": 48.8534100,
            "longitude": 2.3488000,
            "scale": 0.01875,
            "pixmap": "http://adress.server.com/images/00011283841.png"
        },
        {
            "latitude": 48.8534100,
            "longitude": 2.3488000,
            "scale": 0.01875,
            "pixmap": "http://adress.server.com/images/00011283842.png"
        },
        {
            "latitude": 48.8534100,
            "longitude": 2.3488000,
            "scale": 0.01875,
            "pixmap": "http://adress.server.com/images/00011283840.png"
        }
    ]
}

Is this proposal realizable from the server point of view?

kit-ty-kate commented 9 years ago

I globally agree with that. Just two point I want to ask and comment:

LouisDuVerdier commented 9 years ago

OK for the first point (it's just the data organization, so no problem since all data remain here). For the second point, I've seen OSM uses some 256x256px tiles in its view (http://tile.openstreetmap.fr/) so we should probably do the same to simplify our work. A dynamic size would be a bit more complicated to implement, so I would prefer a fixed size. But if you want, we can add a tileSize arg to the GET request.

kit-ty-kate commented 9 years ago

I'm ok for the fixed size tile then.

LouisDuVerdier commented 9 years ago

I have encountered a practical issue about all this: the world is spherical, it's not a rectangle, so the x-scale is not the same as the y-scale (cf http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#X_and_Y). In this article, it is said that there is a few zoom levels. Would it be better to use them? How does it work at your side?

LouisDuVerdier commented 9 years ago

OK, other try: because of the OSM tiling system (url/zoom/x/y.png), we should use the same system to simplify the work. A GET HTTP request would then be: http://adress.server.com/service?service=map&zoom=7&x=10&y=5.

The JSON answer:

{
    "x": 10, // the tile's x coord, according to http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Derivation_of_tile_names
    "y": 5, // the tile's y coord, according to http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Derivation_of_tile_names
    "zoom": 7, // the zoom level, according to http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Zoom_levels
    "pixmap": "http://adress.server.com/images/00011283840.png" // static URI of the image
}

The client would then make the required number of calls, according to its needs. It looks to be also the way GoogleMaps works, and it makes possible for each tile to know easily the exact size and coordinates.

Is that ok for you? I think it is the easiest for you.

kit-ty-kate commented 9 years ago

Sorry for the delay I had a terrible week-end and I couldn't setup the osm database. So for the zoom level I think it's the same as in osm. But for the coordinates, I can't see precisely what the values reflects. It seems that it begins with the full coordinates (lat. and long.) and deals with offsets after but I'm not sure.

LouisDuVerdier commented 9 years ago

What I understand is that for each zoom level, you will have a set of images representing the world, e.g. 4096x4096 for the zoom level 12. Each tile will then represent 0.0879° x 0.0415° of long/lat respectively, and the maximum x value will be 4096. A longitude of 42° should be the same as an x value of 479 (well, not really 479 because we have to apply the formula of http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Derivation_of_tile_names to get the exact value, but you know what I mean).

LouisDuVerdier commented 9 years ago

Resolved.