mapbox / mapbox/sphericalmercator

Mt.Everest Tile not found after converting

Open
#43 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
288
Forks
51
PR merge metrics
No merged PRs in 30d

Description

Hello, I am working on a Mapbox Three.js Helicopter Flight Simulator for Mt.Everest.

It would appear I need the terrain-rgb png tiles to create a texture height mesh. Unfortunately I am unable to get a tile from Mapbox's API. Can you determine if the issue is with this repo?

I was assuming I would enter the coordinates in Long, Lat (reversed) to generate X, Y coordinates and then pipe them into the v4/mapbox.terrain-rgb endpoint for raw png downloads.

https://api.mapbox.com/v4/mapbox.terrain-rgb/9/3209405.2294914094/9654494.533620872.pngraw?access_token=pk.eyJ1IjoibXBhY2Npb25lIiwiYSI6ImNrbjI5bXB1bDE1bDIydm1sZHl3NHRlM3QifQ.22OWoeAEOElNOu0W4ZsdFA

{ res: { message: 'Not Found' } }

Script

const queryMapbox = async () => {
  const merc = new SphericalMercator({
    size: 256,
  });
  const xyFromLatLong = (lat, long, merc) => {
    return merc.forward([long, lat]);
  };

  const zoom = 9;
  const long = 86.7278;
  const lat = 27.6857;
  const xyPos = xyFromLatLong(lat, long, merc);

  try {
    const response = await fetch(
      `https://api.mapbox.com/v4/mapbox.terrain-rgb/${zoom}/${xyPos[0]}/${xyPos[1]}.pngraw?access_token=${process.env.ACCESS_TOKEN}`
    );
    const res = await response.json();|
    
    console.log({ response });
    console.log({ res });
  } catch (err) {
    console.error(err);
  }
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided JavaScript queryMapbox script and inspecting the SphericalMercator forward conversion used to build the terrain-rgb URL. Compare the generated zoom, x, and y values with the Mapbox endpoint response; done means establishing whether the failure is caused by this repository or by the requested API coordinates or endpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.