How Can I get the Location on the Polygon(which is Added as a child Layer to the MainMap)...???
-
Thursday, June 21, 2012 2:33 PM
Hi,
Can u plz help me that.....
1. I have drawn a rectangle using MapPolygon object, as a child Layer.
??? ??? ???
Can i get the Locations Falling within that Layer(that is in that Polygon).
Thanks in advance
prakash kumar
All Replies
-
Thursday, June 21, 2012 2:48 PMOwner
An algorithm for doing a point in polygon type search can be found here: http://msdn.microsoft.com/en-us/library/cc451895.aspx Note this kind of functionality isn't built in and requires some coding. Alternatively, if you data is SQL Server you can always send the point to it and have it check for you.http://rbrundritt.wordpress.com
- Marked As Answer by prakash_light Thursday, June 21, 2012 3:03 PM
-
Thursday, June 21, 2012 3:04 PM
Thnks Richard.....Now i have some way..to do it..let us see...
-
Wednesday, June 27, 2012 1:03 PM
Hi Richard,
The algorithm in the link http://msdn.microsoft.com/en-us/library/cc451895.aspx....is too much time taking....if m testing this one for 500 elements then ...program will stuck...can we have the efficient algorithm....plz...suggest me for this condition....
Thanks in advance
prakash kumar
-
Wednesday, June 27, 2012 1:14 PMOwner
Hi Prakash,
That algorithm is pretty effiecent as it is, there really doesn't get more basic than it is. Note that this type of query is not normally done in JavaScript. Normally this type of query is carried out on the server side or in a database and runs much faster in those cases. You could possibly speed up the algorithm if a do/while loop was used instead of a for loop but this would only make a difference of a few ms.
http://rbrundritt.wordpress.com
- Marked As Answer by prakash_light Thursday, June 28, 2012 3:59 AM
-
Thursday, June 28, 2012 4:20 AM
Hi Richard,
I am writing my query in C# and logic is .....
1. I have the 512 Points or more than that to be tested that they are falling in the Drawn polygon or not.
my looping construct is as like........
Step : foreach(Points in database(512 Pointts))
call below function......
function pointInPolygon(points,lat,lon) { var i; var j=points.length-1; var inPoly=false; for (i=0; i<points.length; i++) { if (points[i].Longitude<lon && points[j].Longitude>=lon || points[j].Longitude<lon && points[i].Longitude>=lon) { if (points[i].Latitude+(lon-points[i].Longitude)/ (points[j].Longitude-points[i].Longitude)*(points[j].Latitude -points[i].Latitude)<lat) { inPoly=!inPoly; } } j=i; } return inPoly; }
IS is correct way to call....I think my Way of calling is Wrong....?????
Thanks in Advance
prakash kumar
-
Thursday, June 28, 2012 6:53 AM
i m writing the code in server side...

