opensciencemap / vtm

a vector-tile map library written in java - running on android, desktop and within the browser
GNU Lesser General Public License v3.0
238 stars 176 forks source link

Vtm- error plotting lines #149

Open Bezzu opened 9 years ago

Bezzu commented 9 years ago

Hi, my application must display some lines from a map file. I load the lines data using the MapDatabase class and add these lines to the map using a VectorTileLayer. The lines plotted are not precise, in fact two parallel lines are shown oblique. This problem is caused when the application reads the line points from the map file and stores them in the GeometryBuffer. The line point coordinates (longitude and latitude) are stored in the map file in unsigned int that is the value in microdegrees. When the application collects these coordinates, it stores them in the GeometryBuffer points variable, that is a float array. Converting the unsigned Int coordinates collected to float some points lose significant digit, causing errors of about 40 cm in the points plotting. This problem is not present in the mapsforge that stores the points in a double variable. So I tried to solve this issue declaring the GeometryBuffer points variable as an array of double and adapting the code to this change. I have resolve this issue but the application reacts slower and has an other problem plotting dashed lines. Has someone already encountered this problem? Can someone help me? Is there a smarter way to solve this issue?

Thanks in advance.

cescorlo89 commented 8 years ago

Hi, I have the same problem, the java Floating variable doesn't have enough digits to represent the mantissa. In fact, the casting of an unsigned int in a float causes the loss of the last significant digits. Has someone an idea to increase the mantissa of a java float?...Is there a smart solution to avoid this casting issue in the vtm?

Thanks in advance.