Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best algorithm to visually separate overlapping vehicles in close proximity on a map?

Tags:

c#

algorithm

I am looking for an algorithm that will allow me to visually separate any two to four vehicles within a large list of vehicles that are close enough together on a map such that they obscure one another. I need to filter out instances where there are more than four vehicles as the vehicles will congregate in certain areas in large quantities and it is unimportant to separate them in those cases. The algorithm should also mark vehicles that have already been processed.

In my problem space, it is more important to know that the vehicles are present and to be able to see information about them, than to have absolutely accurate information as to where they are.

The idea is to add approximately 10 yards (given the map scale that is being used) so individual vehicles can be seen instead of being obscured by other vehicles in close proximity.

I have thought of several ways to do this, but given the quality of the answers here and the fact that somebody might have already done this, I thought I would post the question.

I am adding an image of what is currently shown in order to help clarify as one of the comments suggested (OK, it is not a diagram but this is what is actually shown to the user).

Several of the answers require changing the visual queues used to indicate how many vehicles (golf cars) are in a given location. I don't want to change what the users are expecting visually and have to explain to the users what the meaning is. The answer using a square is closest to what I was looking for but that is just the visual part. I am also looking for the algorithm for how to best traverse the list finding groups of 2 to 4 golf cars that are within n (lets say 5) yards of each other while ignoring larger groupings (cart barn, snack shack, etc). The numbers on the icons correspond to the cart numbers.

This application also allows the user to zoom the map in/out so the further zoomed out the map the more separation is needed between the cars so that they do not visually overlap.

Note in the picture that cars 78 and 62 are obscuring the cars that are behind them.

alt text

like image 677
eesh Avatar asked Nov 06 '22 08:11

eesh


1 Answers

The Google term is label placement. In general this is a complete research area itself and there are no really good general solutions, but for specific scenarios like this there are several suitable implementations. Wikipedia/Automatic label placement is also a good starting point.

According to your image you expect very few overlapping labels, then you can go for a simple greedy algorithm optimized for speed.

like image 172
Albin Sunnanbo Avatar answered Nov 10 '22 17:11

Albin Sunnanbo