NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

HI there! I know the below code calculates the north west corner long/lat coordinates of a tile, but is there a way to calculate the north east, south east or south west corner long/lat coordinates? (I'm terrible at maths...).

I'm programming in java, and any zoom around 17 - 19 would do.

static double tile2lon(int x, int z) { return x / Math.pow(2.0, z) * 360.0 - 180; }

static double tile2lat(int y, int z) { double n = Math.PI - (2.0 * Math.PI * y) / Math.pow(2.0, z); return Math.toDegrees(Math.atan(Math.sinh(n))); }

Thank you very much!

asked 30 May '19, 02:18

xj18205's gravatar image

xj18205
36112
accept rate: 0%


I just realised I can use the NW corner of the surround tiles to work out this answer!

permanent link

answered 30 May '19, 03:06

xj18205's gravatar image

xj18205
36112
accept rate: 0%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×287
×144
×76
×35
×8

question asked: 30 May '19, 02:18

question was seen: 2,038 times

last updated: 30 May '19, 03:06

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum