[OSM-dev] Osmosis Bug Report: Node TileIDs Incorrect

Shaun McDonald shaun at shaunmcdonald.me.uk
Sun Apr 27 12:07:07 BST 2008


Hi Brett,

On 27 Apr 2008, at 11:38, Brett Henderson wrote:

> If somebody knows how the current quad tile implementation is supposed
> to work, please let me know.
>
> I've had a quick look at the error but I don't know how the quad tile
> algorithm should work.  When I implemented this I just copied the C
> implementation, however I found it a little confusing which code I
> should be looking at because the source files didn't all appear to  
> be in
> a single location.  As a result, I may have implemented it wrongly.
>
> This is my java implementation:
>
>    /**
>     * Calculates a tile index based upon the supplied coordinates.
>     *
>     * @param latitude
>     *            The coordinate latitude.
>     * @param longitude
>     *            The coordinate longitude.
>     * @return The tile index value.
>     */
>    public long calculateTile(double latitude, double longitude) {
>        int x;
>        int y;
>        long tile;
>
>        //x = (int) Math.round((longitude + 180) * 65536 / 360);
>        //y = (int) Math.round((latitude + 90) * 65536 / 180);
>        x = (int) Math.floor((longitude + 180) * 65536 / 360);
>        y = (int) Math.floor((latitude + 90) * 65536 / 180);
>

Taking a look at rails:
http://trac.openstreetmap.org/browser/sites/rails_port/lib/quad_tile.rb#L6
it appears that the ruby library is using round too. However, more  
importantly, they use 65535, while you have been using 65536. Being 1  
out could throw this. Try that change and see if it helps.

Shaun

[...]




More information about the dev mailing list