The code clips the asset geometry if the drawn geometry intersects with a LineString/MultiLineString (aka a trail). It selects the entire asset's geometry if it's not a LineString/MultiLineString, like if it's a polygon (aka a building). Previously the code would clip any and all assets, which doesn't make sense because they wouldn't be selecting half of a building. This code prevents a user from selecting half of a building.
Notes
I'm doing some slicing/dicing with turf js functions. This is the best I could find with the available library functions, but if anybody is more knowledgeable about turf, please don't hesitate to point out approach I might've overlooked. Also, let me know if there's a better way to do this in code...it's not the most efficient because we're looping through features more than once. The turf-clip function is looping through like we are, so I took that as inspiration.
Overview
For issue #95.
The code clips the asset geometry if the drawn geometry intersects with a
LineString
/MultiLineString
(aka a trail). It selects the entire asset's geometry if it's not aLineString
/MultiLineString
, like if it's a polygon (aka a building). Previously the code would clip any and all assets, which doesn't make sense because they wouldn't be selecting half of a building. This code prevents a user from selecting half of a building.Notes
I'm doing some slicing/dicing with turf js functions. This is the best I could find with the available library functions, but if anybody is more knowledgeable about turf, please don't hesitate to point out approach I might've overlooked. Also, let me know if there's a better way to do this in code...it's not the most efficient because we're looping through features more than once. The turf-clip function is looping through like we are, so I took that as inspiration.
Testing Instructions