[ka-Map-users] Re: Point Collision and Quantization

Wei Yang, Ng - Wayne wayne at datalinktech.com.au
Fri Aug 11 01:28:12 EDT 2006


Hi all,
This is a part of my email sent to Pg. For the benefit of all, I will 
discuss how this point collision system works.
The point collision system works by reading two attributes in the XML 
file that creates your overlays. Example:
<point id='1234' x='123' y='123' collision='true' col_radius='16'> (Note 
the collision and col_radius values)
if col_radius is not set, the default will be 20 pixels

Basically, if collision detection is activated, we first hide all the 
points (style.visibility='none') in the ovrObjects array.
Create a deep copy of ovrObjects. Scan through the cloned array of 
points and "measuring" the distance of two given
points in pixels. Measurements are done with pythagoras' theorem. 
Colliding points are removed from the cloned array
and are properly consolidated/grouped together so that one collision 
point may be used to represent all of them. The
remaining points within the cloned copy of ovrObjects are then displayed 
again.(style.visibility='block').

Each time the scale level is changed, the resetCollisionPoints function 
is invoked. The code within this method should
be easy to understand. For now, collision areas are denoted by a green 
dot. So if you see those, you know its working.
I have made additional improvements today. Clicking on the green dot 
will display a menu panel showing a list of
collided points. I used the overLib javascript library to achieve this. 
This idea was taken from an earlier post by
sepher. 
http://lists.maptools.org/pipermail/ka-map-users/2006-March/001088.html

overlib can be downloaded from http://www.macridesweb.com/oltest/
and simply add "overlibmws.js" to your index page.
or if you wish to see the basic collision system in action, simply 
comment out
"this.addPointTooltip(collisionPt, html);" in line 593 of 
kaXmlOverlay.js (could be better handled).

As usual, let me know if you want a copy of my file to explore with. I 
will find a way to merge the changes to cvs
in the mean time.
Happy holidays Pg :)

Wayne

Justin George wrote:
> Wayne, I'd be very interested in seeing this, it's been one of the
> things I've had problems implementing on my own. I'm also using a
> somewhat outdated copy of kaXmlOverlay, and would be willing to do the
> merge to the head and write some documentation, I'm unfortunately not
> able to test beyond windows IE and firefox, however, so I'd need some
> help with that.
>
> J
>
>> Date: Thu, 10 Aug 2006 16:38:47 +1000
>> From: "Wei Yang, Ng - Wayne" <wayne at datalinktech.com.au>
>> Subject: [ka-Map-users] Point Collision
>> To: ka-map-users <ka-map-users at lists.maptools.org>
>> Message-ID: <44DAD477.8030907 at datalinktech.com.au>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> Hi all,
>>      2 days ago, I sent a message to Pg and cc a copied of the message
>> to this mailing list. Apparently, it is still
>> awaiting the moderator's decision as the message is too large. I
>> attached a copy of kaXmlOverlay.js to the message
>> as I have recently implemented a point collision system. Please do let
>> me know if you wish to test it out. The version
>> of kaXmlOverlay I was working on is about a month old now. Will that be
>> an issue? Also, is it a wise choice to
>> attach files to the mailing list in future?
>>
>>
>> Cheers,
>> Wayne


More information about the ka-Map-users mailing list