SpatioTemporal / pystare

The Python interface for the SpatioTemporal Adaptive Resolution Encoding (STARE), a unified indexing for geolocated data.
https://pystare.readthedocs.io/en/latest/
12 stars 2 forks source link

wrong ring lookup #81

Open NiklasPhabian opened 3 years ago

NiklasPhabian commented 3 years ago

a relatively harmless looking ring (polygon) yields a wrong result:

xs = array('d', [-83.50488443538553, -83.7, -83.7, 
-83.67112067358016, -83.66907393801182, -83.66554227965247, 
-83.64263147496257, -83.63320937411328, -83.62664108022165, 
-83.61956002347625, -83.61137316124234, -83.59750533380407, 
-83.59332273895319, -83.59425462005464, -83.5903484399285,
 -83.5810869256211, -83.57322555321667, -83.53436445815316, 
-83.51525277469574, -83.50685181985557, -83.48374027209582, 
-83.47450991390139, -83.45, -83.45, 
-83.47240973162377, -83.50488443538553])

ys = array('d', [10.55, 10.55, 10.278107169257183, 
10.297085463823123, 10.345720887309142, 10.360511759110466, 
10.371931475457302, 10.369180219991222, 10.371458806179021, 
10.378249995241163, 10.376069489115707, 10.364449118731898, 
10.354670297296423, 10.33245057843152, 10.32146336494236, 
10.313312134747264, 10.31232223838066, 10.325070807371901, 
10.320794491472668, 10.322225865031669, 10.314743498413748, 
10.29640319944815, 10.300752042488822, 10.448955087106551, 
10.485058914237527, 10.55])

pystare.cover_from_ring(ys, xs, level=12)

yields

array(['0x2f1b640000000009', '0x2f1b7a800000000a', '0x2f1b66000000000b',
       '0x2f1b66200000000b', '0x2f1b66600000000b', '0x2f1b7bc00000000b',
       '0x2f1b28800000000c', '0x2f1b2a000000000c', '0x2f1b2a400000000c',
       '0x2f1b2b000000000c', '0x2f1b2b080000000c', '0x2f1b2b180000000c',
       '0x2f1b2b200000000c', '0x2f1b2ba00000000c', '0x2f1b2f000000000c',
       '0x2f1b34000000000c', '0x2f1b38000000000c', '0x2f1b61000000000c',
       '0x2f1b62800000000c', '0x2f1b62880000000c', '0x2f1b62980000000c',
       '0x2f1b62b00000000c', '0x2f1b62f00000000c', '0x2f1b66480000000c',
       '0x2f1b66500000000c', '0x2f1b66580000000c', '0x2f1b66800000000c',
       '0x2f1b66880000000c', '0x2f1b66900000000c', '0x2f1b66980000000c',
       '0x2f1b66c00000000c', '0x2f1b66c80000000c', '0x2f1b66d00000000c',
       '0x2f1b66d80000000c', '0x2f1b66e00000000c', '0x2f1b66e80000000c',
       '0x2f1b66f00000000c', '0x2f1b66f80000000c', '0x2f1b67a80000000c',
       '0x2f1b67c00000000c', '0x2f1b67c80000000c', '0x2f1b67d00000000c',
       '0x2f1b67d80000000c', '0x2f1b67e00000000c', '0x2f1b67e80000000c',
       '0x2f1b67f80000000c', '0x2f1b72000000000c', '0x2f1b7a000000000c',
       '0x2f1b7a080000000c', '0x2f1b7a100000000c', '0x2f1b7a180000000c',
       '0x2f1b7a200000000c', '0x2f1b7a280000000c', '0x2f1b7a300000000c',
       '0x2f1b7a380000000c', '0x2f1b7a500000000c', '0x2f1b7a600000000c',
       '0x2f1b7a680000000c', '0x2f1b7a700000000c', '0x2f1b7a780000000c',
       '0x2f1b7b400000000c', '0x2f1b7b500000000c', '0x2f1b7b580000000c',
       '0x2f1b7b800000000c', '0x2f1b7b880000000c', '0x2f1b7b900000000c',
       '0x2f1b7b980000000c', '0x2f1b7ba80000000c', '0x2f1b7be00000000c',
       '0x2f1b7be80000000c', '0x2f1b7bf00000000c', '0x2f1b7bf80000000c',
       '0x2f1b7d000000000c', '0x2f1b7e000000000c', '0x2f1b7e100000000c',
       '0x2f1b7e180000000c', '0x2f1b7e400000000c', '0x2f1b7e480000000c',
       '0x2f1b7e580000000c', '0x2f1b7e680000000c', '0x2f1b7f200000000c',
       '0x2f1b7f380000000c', '0x2f1b7fa00000000c'], dtype='<U18')

which looks as follows:

image

I feel like this is connected to https://github.com/SpatioTemporal/pystare/issues/80

NiklasPhabian commented 3 years ago

https://github.com/SpatioTemporal/pystare/pull/82

added test here

michaelleerilee commented 3 years ago

This probably comes up from choosing a bad point and walking rays around the perimeter and counting boundary crossings badly.