EasyGIS.NET icon indicating copy to clipboard operation
EasyGIS.NET copied to clipboard

GetClosestShape Is Driving me Crazy

Open dusko23 opened this issue 1 year ago • 5 comments

I have been struggling for two days to find a cure for a weird problem. I would be grateful if someone could give me a hint.

Scenario: SFmap object named mapSAROSmain contains 80 small Shape Files. image

There are two functions to serve different purposes. The thing is that the body of each function contains GetClosestShape method call.

I iterate through all Shape Files (80 there are) calling GetClosestShape method. Here are two calls, one per each function. image myPOINTd is mouse cursor. myCheckDistance is equal in both functions. mapSAROSmain has raster map drawn.

Time to complete 80 iterations:

  • 53 milliseconds function 1
  • 1714 milliseconds function 2

I have stripped all of the code that might cause an issue. But problem persists.

I have also find one interesting detail in function 2 (the slow one). If mouse cursor is close enough to a shape (record actually) the time to complete single GetClosestShape is ZERO ticks. If mouse cursor is out of myCheckDistance the time to complete single GetClosestShape vary from 0.02 seconds to 1 second. Any hint is highly appretiated.

dusko23 avatar Oct 26 '23 23:10 dusko23