Comments (3)
I'm not 100% sure anymore why I thought using Strings for IDs would be the best choice. I remember dark that I had some problems with huge IDs but I'm not sure whether it was in JavaScript, Java or Python.
I think that problems could arise from the way JavaScript handles big integer values. See http://stackoverflow.com/a/9643650/404522
From an API point of view I used strings because they can handle 64 bit integers without a problem. The problem of handling 64 bit integers only arises on the osm-read implementation side. I thought that using strings in the interface leaves me the design choice to switch to some different way of parsing 64 bit IDs if I detect that the precision of the JavaScript integers is not good enough.
I think I'm going to add a test with a 0xffffffffffffffff ID and see what happens. If such high values can be represented in JavaScript we can change the datatype of ID, UIDs, etc. to integer in order to save some memory.
If the values can not be represented as JavaScript integers with enough precision I'm not yet sure what to do... Strings are "native" JavaScript datatypes. This makes comparing them and using them as keys in objects easy. Thats why I'm currently not very convinced of something like { lower32bits: 123, higher32bits: 456 } as representation for 64 bit integers.
What do you think?
from osm-read.
I think I'm going to add a test with a 0xffffffffffffffff ID and see what happens. If such high values can be represented in JavaScript we can change the datatype of ID, UIDs, etc. to integer in order to save some memory.
Actually, in JavaScript every "number" is stored as a double precision float which can hold Integers up to about 2^52 without rounding errors. 2^64 wouldn't work, though.
from osm-read.
Thanks for your responses, I feared there would be an issue with the number type. So I guess we just leave it as is.
An idea might be to have it configurable, so the user can decide to take the risk of not supporting 64-bit ids properly. But not sure what the actual benefit would be and not the highest priority right now, so closing.
from osm-read.
Related Issues (20)
- lat lon are not in WSG84 format HOT 5
- Relations HOT 2
- Relation members output format HOT 6
- Pause/Resume HOT 12
- Parser getting stuck HOT 1
- Cannot read property 'byteLength' of undefined HOT 5
- Example pbf.html is Broken HOT 6
- Too Much Recursion HOT 4
- Get tag "center" from overpass-api response xml HOT 2
- Invalid typed array length in arrayBufferReader Line 12 HOT 1
- Allocation failed - process out of memory HOT 1
- Tags unresolved HOT 3
- Vulnerability in protobuf dependencies HOT 2
- pbfParser in node.js and "TypeError: Invalid non-string/buffer chunk" HOT 9
- Is it possible to do any progress indication HOT 1
- Module not found: Error: Can't resolve '../../node_modules/zlibjs/bin/inflate.min.js' HOT 1
- Would exposing an async iterator API suit this library? HOT 3
- Why not store IDs as BigInt? HOT 4
- primitivegroup.length - Is it always 1? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osm-read.