Skip to content
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

fix: preserve orientation properties of hilbert curve #7 #9

Merged
merged 4 commits into from Oct 31, 2022

Conversation

becheran
Copy link
Owner

Not fully ready to merge.

Update docs and double check implementation before merging

@hallahan
Copy link

Awesome, I'll give it a try tomorrow morning 👍

@hallahan
Copy link

Works great for me!

src/lib.rs Outdated
@@ -113,8 +114,7 @@ where

let coor_bits = (core::mem::size_of::<T>() * 8) as u32;
let useless_bits = (x | y).leading_zeros() & !1;
let useful_bits = coor_bits - useless_bits;
let order = useful_bits;
let order = (coor_bits - useless_bits) as u8 + (order & 1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps reword this as lowest_order? It won't be obvious unless reading our discussion that you are optimizing here by figuring out the lowest order that will produce the correct Hlibert curve.

Perhaps even in the README this could be explained? I think this is a motivating factor for someone to use your crate. For example:

let h = xy2h(3, 4, 63)

Saves a ton of computation!

If you're sorting GPS telemetry from all the phones in New Zealand, your lowest order will be similar to the specified order, thereby taking longer to compute the Hilbert location.

z25 x32924236 y21009587 h780201608115701

Screen Shot 2022-10-31 at 9 49 05 AM

But... if you want a Hilbert location in Alaska at a High zoom, it should be just as fast as the location at a lower zoom.

Screen Shot 2022-10-31 at 9 50 26 AM

z25 x2193040 y7118510 h27434051735036

A more extreme example:

z25 x5 y1 h56

@becheran becheran marked this pull request as ready for review October 31, 2022 20:57
@becheran becheran merged commit 500aa05 into main Oct 31, 2022
@becheran becheran deleted the fix_reorientation branch January 5, 2023 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants