You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With machine generated geojson it's more space saving to store up to 32 flags in a single integer value.
Design Alternatives
The only alternative is to store boolean properties for each flag, which creates unnecessary overhead and requires us to write a boolean check expression for each flag instead of checking for multiple flags only once with an and operation.
Right now for each flag I want to check inside an integer I have to create an expression, which shifts the bit to the right with a division by powers of 2 and modulo 2 to extract the bit for the flag == 1 check ['==', ['%', ['floor', ['/', ["get", "location-type"], 1<<flagIndex]], 2], 1]
Design
With bitwise operators we could do a check for multiple flags within a simple and operation: ['&', ["get", "location-type"], 0b10101]
Implementation
So for the flag checking use case it would be enough to have the & operator expression or labelled as 'hasFlags' expression.
But you could also just add all bitwise operators to the math expressions as
'&' and
'xor' because ^ is already in use
'not' because ! is already in use
'|' or
'<<' left shift
'>>' right shift
The text was updated successfully, but these errors were encountered:
Motivation
With machine generated geojson it's more space saving to store up to 32 flags in a single integer value.
Design Alternatives
The only alternative is to store boolean properties for each flag, which creates unnecessary overhead and requires us to write a boolean check expression for each flag instead of checking for multiple flags only once with an and operation.
Right now for each flag I want to check inside an integer I have to create an expression, which shifts the bit to the right with a division by powers of 2 and modulo 2 to extract the bit for the flag == 1 check
['==', ['%', ['floor', ['/', ["get", "location-type"], 1<<flagIndex]], 2], 1]
Design
With bitwise operators we could do a check for multiple flags within a simple and operation:
['&', ["get", "location-type"], 0b10101]
Implementation
So for the flag checking use case it would be enough to have the & operator expression or labelled as 'hasFlags' expression.
But you could also just add all bitwise operators to the math expressions as
'&'
and'xor'
because ^ is already in use'not'
because ! is already in use'|'
or'<<'
left shift'>>'
right shiftThe text was updated successfully, but these errors were encountered: