MapMath

CHAPTER 15

Practice problem set

Eight worked exercises with full step-by-step solutions, covering coordinate conversions, Haversine distance, tile math, and spherical area.

3 min read

Try these by hand or in code. Solutions follow. Working through problems manually is the fastest way to spot which formulas you've actually internalized versus which ones you've just read.

optional — skip if familiarrefresher

These problems draw on Chapters 1–13. If you get stuck, the chapter number is noted in parentheses after each problem. Don't check the solution until you've made a genuine attempt — even an incorrect one reveals where your mental model breaks down.

Problems

P1. Convert 40° 26' 46.302" N, 79° 58' 56.903" W to decimal degrees.

P2. What's the distance (Haversine) between Paris (48.8566, 2.3522) and New York (40.7128, -74.0060)?

P3. What's the initial bearing from Paris to New York?

P4. At zoom level 8, which tile contains Tokyo (35.6762, 139.6503)?

P5. A drone flies 2 km on bearing 045° from (0, 0). Where does it end up?

P6. Compute a bounding box for a 10 km radius around Karachi (24.8607, 67.0011).

P7. What's the area of a polygon with vertices (in lon, lat): (0, 0), (1, 0), (1, 1), (0, 1)? (Use the spherical formula.)

P8. A point at zoom 10 has world pixel coordinates (550000, 380000). What's its lat/lon?


Solutions

S1.

lat=40+26/60+46.302/3600=40.4462°\text{lat} = 40 + 26/60 + 46.302/3600 = 40.4462° lon=(79+58/60+56.903/3600)=79.9825°\text{lon} = -(79 + 58/60 + 56.903/3600) = -79.9825°

S2. Haversine:

Δφ=8.1438°=0.14217 rad,Δλ=1.33271 rad\Delta\varphi = -8.1438° = -0.14217 \text{ rad}, \quad \Delta\lambda = -1.33271 \text{ rad} a=sin2(0.07109)+cos(0.85245)cos(0.71081)sin2(0.66635)0.1946a = \sin^2(-0.07109) + \cos(0.85245)\cos(0.71081)\sin^2(-0.66635) \approx 0.1946 c=2arctan2(0.1946,0.8054)0.9170c = 2 \arctan2(\sqrt{0.1946}, \sqrt{0.8054}) \approx 0.9170 d6,371,008.8×0.91705,840 kmd \approx 6{,}371{,}008.8 \times 0.9170 \approx 5{,}840 \text{ km}

S3.

y=sin(1.33271)cos(0.71081)0.7359y = \sin(-1.33271)\cos(0.71081) \approx -0.7359 x=cos(0.85245)sin(0.71081)sin(0.85245)cos(0.71081)cos(1.33271)0.2936x = \cos(0.85245)\sin(0.71081) - \sin(0.85245)\cos(0.71081)\cos(-1.33271) \approx 0.2936 θ=arctan2(0.7359,0.2936)68.18°\theta = \arctan2(-0.7359, 0.2936) \approx -68.18° bearing291.82°(WNW — NY is to the west and slightly north)\text{bearing} \approx 291.82° \quad \text{(WNW — NY is to the west and slightly north)}

The WNW bearing makes geographic sense: New York is almost due west of Paris, with a slight northward component visible from the non-trivial latitude difference.

S4.

n=256n = 256 x=256×(139.6503+180)/360=227x = \lfloor 256 \times (139.6503 + 180)/360 \rfloor = 227 y=256×0.3939=100y = \lfloor 256 \times 0.3939 \rfloor = 100

Tile: (8, 227, 100)

S5.

δ=2000/6,371,008.8=0.000314\delta = 2000 / 6{,}371{,}008.8 = 0.000314 θ=π/4\theta = \pi/4 φ2=arcsin(0.000222)0.01272°\varphi_2 = \arcsin(0.000222) \approx 0.01272° λ2=arctan2(0.000222,1.0000)0.01272°\lambda_2 = \arctan2(0.000222, 1.0000) \approx 0.01272°

End: (0.0127°, 0.0127°)

Equal latitude and longitude offsets make sense — at the equator, going NE means equal N and E components.

S6.

Δφ=10000/6,371,008.80.0899°\Delta\varphi = 10000/6{,}371{,}008.8 \approx 0.0899° Δλ=0.0899/cos(24.86°)0.0992°\Delta\lambda = 0.0899/\cos(24.86°) \approx 0.0992°

Box: lat [24.7708,24.9506][24.7708, 24.9506], lon [66.9019,67.1003][66.9019, 67.1003]

S7. Apply the spherical polygon area formula at small scale:

Area12,180 km2\text{Area} \approx 12{,}180 \text{ km}^2

Sanity check: at the equator, 1° × 1° ≈ 111 × 111 ≈ 12,321 km². Close.

Chapter 15 · Paid content

Continue reading "Practice problem set"

You've reached the end of the free preview. Unlock all 22 paid chapters, including distance math, bearings, polygons, spatial indexing, and 3D map rendering — plus a downloadable PDF and the companion code repo.

  • All 22 paid chapters with worked examples
  • Downloadable PDF for offline reading
  • Companion GitHub repo (JavaScript + Python)
  • Free updates for life

Multiple payment options including Wise, PayPal, and bank transfer.