How to get Cesium's TileBoundBox?

I made a PBF parsing tool with reference to mapbox/mercantile. When I used it to create the PBF data, it was somewhat deviated from Cesium’s coordinates. I think it should be caused by the inconsistency of the TileBoundBox algorithm. So can I find the ratio difference between them? Or how can I get the corresponding BoundBox by TileID (10/615/400) (z/x/y)?

1 Like

Just a shot in the dark, but have you checked the location of your WorldTerrain? We saw similar issues with inconsistent coordinates, but the issue was our WorldTerrain’s transform location was not set to 0, 0, 0, causing coordinates to be off like you have.

As an aside, would you be willing to share how you built a PBF parser? I was thinking of building one but wasn’t sure where to start

1 Like

The further these coordinates are from the origin, the larger the offset will be. So I guess it should be a misalignment between the ellipsoid and the plane.It should have a corresponding function conversion in Cesium, but I don’t know which one.

PBF I parsed with mapbox/vtzero.

Hi @Xiaoguang ,

Your project looks pretty cool! Let me ask some questions to try to understand your issue:

• How are you converting from mercantile tiles to LongLat / ECEF?
• Are you using the georeference system to position the tiles?
• What are you referring to by the “TileBoundBox” algorithm?

I’m not familiar with mercantile, but my bet is that this is a spherical projection that you are trying to make work on an ellipsoid, which will cause issues close to the ground. Cesium uses ECEF and WGS84 Longitude-Latitude-Height as our coordinate systems.

• Nithin

I am new to GIS and I have no basic knowledge of GIS. I just made a conversion with reference to the mapbox/mercantile library. I think the reason for this should be that mapbox/mercantile is a horizontal plane, and Cesium is an ellipsoid, and the gap between them should be this feeling. So how should I do the conversion?
This is the code for the Latitude and Longitude ToMercator.

``````FVector2D UGomapCoreLibrary::CoordToMercator(const FCoord2D& Coord)
{
FVector2D mercator;
mercator.X = EarthRadius * (Coord.Longitude * DOUBLE_PI / 180.0);
if (Coord.Latitude <= -90)
{
mercator.Y = double(123);
}
else if (Coord.Latitude >= 90)
{
mercator.Y = double(123);
}
else
{
mercator.Y = EarthRadius * log(tan(DOUBLE_PI * 0.25 + 0.5 * (Coord.Latitude * DOUBLE_PI / 180.0)));
}

return mercator;
}
``````