-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GeoJSON to flat binary arrays #690
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kylebarron This looks very good indeed!
I'd land this right now if maintainers weren't prepping for the 2.1 release.
@xintongxia as soon as you have cut 2.1-release, let's land this.
We need to add
-
modules/gis/docs/api-reference/features-to-binary.md
- At least some trivial test cases (just something trivial that at least makes sure this code is not "dead on arrival", e.g. find an existing geojson snippet in some
modules/*/test/data
folder and reuse it).
I'll try to add some tests later tonight. Do you have any other suggestions for the properties? When this is integrated with Something like this? Where we remove the coordinates from the geometry object?
Or do you have in mind returning all properties in typed arrays, where the value is repeated for each vertex? Even strings? That might become hard to work with. |
If you want to provide properties with the binary arrays
But yes, I was thinking that we would generate additional binary arrays (for numerical properties only). |
I've been thinking about how I'd use the returned binary data, and in order to apply styling in Deck.gl, I'd need access to the feature properties, including string types. Theoretically you could encode UTF-8 characters in a binary array, but I'm not sure if that's worth it. To make sure I'm on the same page; you're thinking something like (properties in normal objects): {
points: {
// Array of x, y or x, y, z positions
positions: {value: Float32Array, size: coordLength},
// Array of original feature indexes by vertex
objectIds: {value: Uint32Array, size: 1},
// Array of property objects
properties: [
{...}
]
},
...
} (binary numeric properties and string properties in objects) {
points: {
// Array of x, y or x, y, z positions
positions: {value: Float32Array, size: coordLength},
// Array of original feature indexes by vertex
objectIds: {value: Uint32Array, size: 1},
// Object with numeric properties
numericProperties: {
propertyName: {value: Float32Array, size: 1}
}
// Array of string property objects
properties: [
{...}
]
},
...
} |
Yes this looks good. For what its worth, I tend to think in terms of returning "columnar tables", so I would personally choose not to have any substructure for properties, but have all binary columns at the top level. In addition we could opt for glTF style accessor names for positions:
To reduce the risk of conflicts, you could name the generated numeric properties as Some options:
|
@kylebarron loaders.gl 2.1 has released and branched off so we can land this on master as soon as you are ready and iterate in additional PRs. |
I'm struggling with the test scaffolding. What's the preferred way to load a JSON object into the test?
|
A couple questions regarding Deck.gl's docs say
|
Yes agree that number of vertices is better. Also this means that the array should not change if we switch between 2D and 3D coordinates.
Let me say that from the perspective of returning a "columnar table", it is desirable that all columns with fixed-length elements are of the same length (as in number of rows). If e.g. deck.gl currently needs a different format, I'd make that an option. |
Thanks, I'll update that. Do you have a suggestion for fixing the file not found error on the geojson test data? |
Yes sorry, this PR is becoming too big, hard to catch all the questions...
|
Sorry to drag it out! I did discover that mixed coordinates are currently handled incorrectly, i.e. if only some of the coordinates have 3 dimensions, some values in It looks like tests are failing on Node 10 because I use |
You can add a simple helper function |
Sorry got distracted. Finally green! |
@ibgreen
Ref #685
The return data is of the format:
I suppose thatpositionFormat
of eitherXY
orXYZ
should also be returned.Float32Array
, but can optionally be changed toFloat64Array
secondPass
would be helpful to keep code cleaner and test them individually, but currently functions are impure, which feels wrong. I'm not sure the best way to fix that.export
ed functions? Or should I just test the exported top-level function?