Completed
Last Updated: 08 Mar 2023 08:16 by ADMIN
Release R1 2023 SP1
Dominik
Created on: 10 Jan 2023 13:10
Category: Map
Type: Bug Report
1
Map: VisualizationLayer.GetItemsInRectangle returns incorrect LineData objects

Good Afternoon,

we use the RadMap's SelectionRectangleChanged event to allow the user to (de)select map elements with the box. In the event handler we use the layer's GetItemsInRectangle function to see what is within the selected area but this is where we encounter a problem with LineData objects. Dragging a selection rectangle that does not touch an edge but is close enough to it (likely within the bounding box of the LineData) it incorrectly recognizes the line as within the rectangle. See the attached screenshot for an example of a selection rectangle that should contain no elements within but actually reports the long line to its right as an element it contains. This can also be reproduced with the attached project:

  • Ctrl + Mouse Left to drag a selection rectangle
  • Mouse Left to pan, mouse wheel zo zoom. Shift + Mouse Left for zoom rectangle
  1. Draw a selection rectangle on the very left or right outside the elements: Debug Output reports "Selected Edges: 0"
  2. Draw a selection rectangle close to an edge but not touching it: Debug Output reports "Selected Edges: 1"
  3. Draw selection rectangle that contains (parts of) an edge: Debug Output reports "Selected Edges: 1"

Regards
Dominik Schacht

 

Attached Files:
3 comments
ADMIN
Dilyan Traykov
Posted on: 13 Jan 2023 16:56

Hello Dominik,

I'm glad to hear that you've managed to find a viable solution for your scenario and would like to thank you for sharing it with our community.

For anyone who uses this approach, I just want to point out that the method of the LocationRect is "IntersectWithLine" and not IntersectsWithLine as seen in the code snippet.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Dominik
Posted on: 13 Jan 2023 10:00

Hello Dilyan,

thanks for taking this up as a proper bug report and your suggested workaround. We implemented it using the LocationRect's IntersectWithLine instead of rolling our own version of line-intersection-detection:

            

var edgesInSelection = EdgeLayer.GetItemsInRectangle(e.Rect); var linesToExclude = edgesInSelection.OfType<LineData>().Where(ed => !e.Rect.IntersectsWithLine(ed.Point1, ed.Point2)); var filteredEdges = edgesInSelection.Except(linesToExclude);

ADMIN
Dilyan Traykov
Posted on: 13 Jan 2023 09:18

Hello Dominik,

Thank you for the provided image and sample project.

I can confirm that I was able to replicate the issue at my end and can state that this is a bug in the GetItemsInRectangle method. I have thus converted this thread to a bug report. I've also awarded you some Telerik points for bringing this to our attention.

For the time being, I can only suggest to exclude the LineData objects from the selection by creating a suitable method. You can try to implement a method similar to the one discussed in this thread: How to know if a line intersects a rectangle.

            var edgesInSelection = EdgeLayer.GetItemsInRectangle(e.Rect);
            var linesToExclude = edgesInSelection.OfType<LineData>().Where(ed => !LineIntersectsRect(ed.Point1, ed.Point2, e.Rect));
            var filteredEdges = edgesInSelection.Except(linesToExclude);

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.