Connecting Tech Pros Worldwide Forums | Help | Site Map

extract the unique node id given the x and y coordinates

Newbie
 
Join Date: Mar 2009
Posts: 3
#1: Mar 26 '09
Hi,

I need to get the unique node assosicated given 2 sets of x and y coordinates.
I have the start and end coordinates of a selected region. And now I need to get the unique ID associated with both of it.

Please do let me know as soon as possible as to how I can go about doing this.

Thanks..
avz

JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Mar 26 '09

re: extract the unique node id given the x and y coordinates


Quote:

Originally Posted by avvz View Post

Hi,

I need to get the unique node assosicated given 2 sets of x and y coordinates.
I have the start and end coordinates of a selected region. And now I need to get the unique ID associated with both of it.

You have to give some more detail: how are those x,y,ID triples stored? What is/are stored in those two sets? Just (x,y) coordinates or the Carthesian product of all coordinates? Are you looking for a position on a (geographical) map?

kind regards,

Jos
Newbie
 
Join Date: Mar 2009
Posts: 3
#3: Mar 26 '09

re: extract the unique node id given the x and y coordinates


Hi Jos,

Thank you for replying.
The x and y coordinates, are the coordinates where the screen starts at (0,0),
So when the mouse clicks to select an area, (assume a square ), then i get the top left x y position and the bottom right x y position.
So now that I have these values, I need to get the unique ID from the DOM tree. I learnt that for each element on the HTML page there is a unique node id associated with it.
So I need to get the unique node ids with the pair of x n y coordinates I have got.
Please do let me know if you need more information.

Thanks,
Avanthi
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#4: Mar 27 '09

re: extract the unique node id given the x and y coordinates


For every component in that DOM tree you need to get the (x,y) (w,h) values (the top/left coordinate and width and height) and check whether or not they lie inside the given (x,y) (w, h) values. If the z value of those components is available as well, take the component which is nearest to the top of the z stack.

kind regards,

Jos
Newbie
 
Join Date: Mar 2009
Posts: 3
#5: Mar 27 '09

re: extract the unique node id given the x and y coordinates


Hi Jos,

Thanks for the reply. Actually that is simliar to the logic I was thinking, but I just needed some code to go about doing this. So is there some code which I could get from anywhere?
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#6: Mar 27 '09

re: extract the unique node id given the x and y coordinates


Quote:

Originally Posted by avvz View Post

Hi Jos,

Thanks for the reply. Actually that is simliar to the logic I was thinking, but I just needed some code to go about doing this. So is there some code which I could get from anywhere?

Do you know how to iterate over your components in your DOM? If so you have solved the major part of your problem already.

kind regards,

Jos
Reply

Tags
node id extraction