robertleeplummerjr / Leaflet.glify

fully functional, ridiculously fast web gl renderer plugin for leaflet
https://robertleeplummerjr.github.io/Leaflet.glify
MIT License
476 stars 84 forks source link

Double precision on WebGL for mapping centimetric points #54

Open mathieugalle opened 4 years ago

mathieugalle commented 4 years ago

Hello,

I have a use case where I need to plot a very large number of centimetric points.

As mentioned on this blog, WebGL projected points are jittering on a grid when the zoom level is too important.

I managed to emulate double types on webGL to pass the exact point position, and avoid this jittering. An example here

Is this in the scope of this library ?

I will try to add this functionality (if I get some time) but I am not sure where to add it. Is it useful only for Points, or also for polygons ?

Would a centimetric boolean on the settings be the right place for this ?

As explained here, it is also possible to add double precision only on the viewport position. This removes the jittering, but points are still placed on a grid (because their precision is still float). But it has the advantage of needing only one more uniform value to the program, instead of 2 more floats per point.

Would a halfCentimetrical setting for this be useful too ?

I will try to propose a pull-request for this if some people have this problem too.

robertleeplummerjr commented 4 years ago

If it isn't to heavy, and can be turned on/off, I'd be up for it.

nurenda commented 3 years ago

If it isn't to heavy, and can be turned on/off, I'd be up for it.

Is there any news about ths issue? I really need too this centimetrical precision, but my skills in javascript are far from optimal. In fact, I am using leaflet.glify from R coding, through the leafgl port by Tim-Salabim...

mathieugalle commented 3 years ago

I finally gave up because of limited time and because this function didn't seem to interest a lot of people. This function also changed a lot of stuff on the shaders handling and it seemed like it was not worth it :-/

It's not simply a on/off functionnality. The way points are sent to the graphic card is completely different.

If you want to dig into how to display centimetric points in webGL, I did a demo here

Otherwise, just try to use standard leaflet points on a leaflet canvas :-/ I finally resolved my own problem by pre-computing images on the server side with all points combined.

I'll try to resurrect this project if I get a little time for this. Sorry in advance if I don't.

kkdd commented 3 years ago

I have realized that this kind of precision errors in Leaflet.glify is over 1 meter in displayed positions, when compared to faistos18's webGL_leaflet_precise_points. Note that both use the same points data.

glify image

robertleeplummerjr commented 3 years ago

I do have interest

kkdd commented 3 years ago

I have just found the following package addressing this problem:

kkdd commented 2 years ago

I think that the mathieugalle's global emulation for double-precision webGL (https://github.com/mathieugalle/faistos18.github.io) for leaflet.js seems promising.