visgl / deck.gl

WebGL2 powered visualization framework
https://deck.gl
MIT License
12.11k stars 2.08k forks source link

[Bug] 2D object is smaller than 3D on the map #9162

Open yaras-phoenix opened 1 week ago

yaras-phoenix commented 1 week ago

Description

  1. Created a square polygon in QGIS with a side = 2000.256 m. image
  2. Created a GLB-model using Blender with the same size and 1m high. image
  3. I expected the size to be at least almost equal but given the 1m height the difference seems to be much bigger. image

Flavors

Expected Behavior

No response

Steps to Reproduce

Using codepens from deck.gl GeoJSON layer and Scenegraph layer docs made my own here. Links to sample objects (JSON and GLB) are attached in the code.

Environment

Logs

No response

felixpalmer commented 1 week ago

Does it work if in QGIS you use Cartesian instead of Ellipsoidal?

yaras-phoenix commented 4 days ago

Does it work if in QGIS you use Cartesian instead of Ellipsoidal?

I work in EPSG:3857 Pseudo-Mercator so cartesian gives me irrelevant 3385 meters. If I change QGIS CRS to, let's say, WGS_1984_Complex_UTM_Zone_30N (ESRI:102580), Cartesian measurement on this object gives 2000.00 meters.

Anyway, it is nowhere near the difference mentioned above.

yaras-phoenix commented 4 days ago

By the way, using Turf.js I measured distance between [ -5.280356221393128, 53.86928337707964 ] and [ -5.249963734890388, 53.869857228664557 ] and got ~1993.65 meters. This seems like something very close to what I see. Can this be any helpful?

Pessimistress commented 4 days ago

using Turf.js I measured distance between and got ~1993.65 meters.

Yes, I believe that is the difference you see.

yaras-phoenix commented 4 days ago

Is there a way to avoid this behaviour when 2d and 3d object differ in size in Deck?

Pessimistress commented 4 days ago

What exactly is the bug you are reporting here? The GeoJSON you supply is smaller than the mesh and the rendering result is true to the data.

yaras-phoenix commented 3 days ago

The problem is that every desktop GIS I use measures this object at ~2000.25: QGIS, GeoMedia, ArcGIS. And when it is published using Deck, I get 1993.5. building measure geomedia building measure arcgis

yaras-phoenix commented 3 days ago

Trying to go deeper I found a clue in Postgis docs. There are 2 functions there: ST_DistanceSphere and ST_DistanceSpheroid. They give me the same difference (1993.65745225 and 2000.2556515777933 respectively) and they relate to slightly different world spaces.

It seems desktop GIS applications work with spheroids and web applications work with spheres so the same data gives different result. But 3D model in the scenegraph layer was generated in different, cartesian environment.

So my question would be: is it possible to somehow bring all my data into line so they would be the same on the deck map?

ibgreen commented 2 days ago

@yaras-phoenix Your model data in 3D tiles might be in meter offsets where each tile has a lng/lat anchor. You could try to hook into the tile loading and use something like @math.gl/proj4 to reproject that anchor from spheroid to spherical coordinates or vice versa. It would likely take you a bit of fiddling to figure out where and how to hook in and which coordinate systems to use in the reprojection and how to specify them.

ibgreen commented 2 days ago

More precisely the lng/lat anchor is probably calculated by loaders.gl from the WGS84 world centric coordinates, you might also be able to access the WGS84 "anchor" coordinates in the loaded tile and reproject directly from those.