Commit 5609c3d0 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

fix unique points connecting several lines

parent e154363c
Pipeline #9880 failed with stages
in 4 minutes and 27 seconds
......@@ -116,4 +116,6 @@ class Raster:
det = gm[5]*gm[1]-gm[2]*gm[4]
pixx = ((lon-gm[0])*gm[5]-(lat-gm[3])*gm[2])/det
pixy = ((lat-gm[3])*gm[1]-(lon-gm[0])*gm[4])/det
return self._data[pixy.astype(int), pixx.astype(int)]
pixy = _tools.np.clip(pixy.astype(int),0,self._data.shape[0]-1)
pixx = _tools.np.clip(pixx.astype(int),0,self._data.shape[1]-1)
return self._data[pixy, pixx]
......@@ -47,7 +47,12 @@ def _generate_unique_points(x):
eps = _tools.np.linalg.norm(bbmax-bbmin)*1e-12
eps = 1e-12
cid = 0
for p0, p1 in tree.query_pairs(eps):
pairs = _tools.np.array(list(tree.query_pairs(eps)))
#sorting the pairs is necessary to handle points connecting more than 2 lines
pairs.sort(axis=1)
pairsint64 = pairs[:,0].astype(_tools.np.int64)*2**32+pairs[:,1].astype(_tools.np.int64)
pairs = pairs[pairsint64.argsort(),:]
for p0, p1 in pairs:
uid = max(unique_id[p0], unique_id[p1])
if uid == -1:
uid = cid
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment