Wrong location returned when accessing data in dfsu file using read
macrophanerophyte opened this issue ยท 3 comments
Describe the bug
When reading dfsu sigmaz files with ds = mikeio.open(file); col = ds.read(x=x, y=y), it happens that the position returned is rather far from the (x, y) point.
To Reproduce
This happens when the the (x,y) point is close to a node and therefore is not contained in the 2 nearest elements to the point (step 3 in FM_Geometry._find_element_2d). I think in the function _find_element_containing_point_2d of "FM_Geometry", the node coordinates should be obtained via "self._geometry2d.node_coordinates" and not "self.node_coordinates".
At line 731 of FM_Geometry: ids[k] = many_nearest[lid] if lid > 0 else -1
-1 is returned if no element are found to contain the point, which is then interpreted as the index of the last element and returns the wrong location
System information:
- MIKE IO version: 1.2.4
Thanks for reporting. We will need to fix this.
@macrophanerophyte great username ๐
Fixed in #541