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 GeoPatch algorithm #253

Closed
4 tasks done
ghost opened this issue Mar 11, 2022 · 1 comment
Closed
4 tasks done

Fix GeoPatch algorithm #253

ghost opened this issue Mar 11, 2022 · 1 comment
Assignees
Labels
bug Something isn't working P2P Involve P2P networking

Comments

@ghost
Copy link

ghost commented Mar 11, 2022

This is an issue in the current algorithm raised in the #238
There is a problem with the last digit of the geo patch as it's not match the geo coordinates.

Solution:
Rebuild the Geo-Patch ID Algo Entirely: (takes only 5-10 lines of code)
image.png

Geolocation patch for a node is represented by 3 Digits, for example “XYZ” where
First Digit (X) is the longitude patch id
Second Digit (Y) is the latitude patch id
Third Digit (Z) is for better precision within the patch
First Digit and Second Digits give the patch ID, the third digit gives more precision

For example on the graph where a node is represented by C68, where
C is the longitude patch id
6 is the latitude patch id
8 is the node’s precision within the C6 Patch
Digits can vary from [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F]

  • Step 1: (longitude, latitude)
    Obtain the Geolocation represented in terms of longitude (-180,180), latitude (-90,90).
    Eg 1: Node A = (82, 36) (82 is longitude and 36 is latitude)
    Eg 2: Node B = (-82, 36) (-82 is longitude and 36 is latitude)
    Eg 3: Node C = (82, -36) (82 is longitude and -36 is latitude)
    Eg 4: Node D = (-82, -36) (-82 is longitude and -36 is latitude)

  • Step 2: (longitude_reference, latitude_reference)
    (longitude_reference, latitude_reference) = (longitude / 22.5, latitude / 22.5)
    Eg 1: (longitude_reference, latitude_reference) of Node A(82, 36) = (3.64, 1.6)
    Eg 2: (longitude_reference, latitude_reference) of Node A(-82, 36) = (-3.64, 1.6)
    Eg 3: (longitude_reference, latitude_reference) of Node A(82, -36) = (3.64, -1.6)
    Eg 4: (longitude_reference, latitude_reference) of Node A(-82, -36) = (-3.64, -1.6)

  • Step 3: (First Digit, Second Digit)
    First Digit & Second Digit = [8, 9, A, B, C, D, E, F, 0, 1, 2, 3, 4, 5, 6, 7, 8]
    Graphical Value in Range = [-8,-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8]
    Assign the first digit and second digit based on the graphical range

  • Step 4: (longitude_second_reference, latitude_second_reference)
    Calculate the Third Digit for better precision
    (longitude_second_reference, latitude_second_reference) = decimal portion of (longitude_reference, latitude_reference)
    If decimal portion of (longitude_reference, latitude_reference) is negative subtract 1 by that number
    Eg 1: Node A = (82, 36) (82 is longitude and 36 is latitude)
    (longitude_reference, latitude_reference) of Node A = (3.64, 1.6)
    (longitude_second_reference, latitude_second_reference) of Node A = (0.64,0.6)
    Eg 2: Node B = (-82, -36) (-82 is longitude and -36 is latitude)
    (longitude_reference, latitude_reference) of Node B = (-3.64, -1.6)
    (longitude_second_reference, latitude_second_reference) of Node A = (0.36,0.4)
    image.png
    Based on the decimal value range, add the third digit

@ghost ghost added the bug Something isn't working label Mar 11, 2022
@ghost ghost assigned internet-zero Mar 11, 2022
@ghost ghost added the core team Assigned to the core team label Mar 11, 2022
@ghost ghost mentioned this issue Mar 15, 2022
2 tasks
@ghost
Copy link
Author

ghost commented Mar 15, 2022

@I-Archer-Zero Please add more descriptive and test cases.
The tasks provided are already implemented, please refer to #238 issue. (Problem statement: #238 (comment))

Neylix added a commit to Neylix/archethic-node that referenced this issue Mar 24, 2022
@ghost ghost added P2P Involve P2P networking and removed core team Assigned to the core team labels Mar 24, 2022
ghost pushed a commit that referenced this issue Apr 19, 2022
* Update geo patch calculation and correct out of bound index
* Improve tests to check near location city
* Fixes #253
@ghost ghost closed this as completed Apr 19, 2022
ghost pushed a commit that referenced this issue May 6, 2022
* Update geo patch calculation and correct out of bound index
* Improve tests to check near location city
* Fixes #253
@ghost ghost mentioned this issue May 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2P Involve P2P networking
Projects
None yet
Development

No branches or pull requests

2 participants