Tips and Tricks using GIS BigData, ArcGIS APIs and other fun stuff :-)

Monday, May 4, 2009

Street Path Finding in AS3

Just finished reading Keith Peter's ActionScript 3.0 Animation book, and I very highly recommend it. Chapter 4 is all about pathfinding using A* but is based on a tiled grid network. So I adjusted it, in such a way that the nodes and arcs are derived from street features off a shapefile. The resulting application enables you to select a starting and ending street intersection and a path is displayed. In addition, you can add street barriers so that the calculated path will go around the defined barriers. The nodes and arcs are spatially indexed. This enables live reverse geocoding as the mouse moves - that means that once the mouse is close enough to a street segment, a snap point is calculated and based on the side of the street, an interpolated address is calculated and displayed. Check out the application here, make sure to zoom in to enable snapping and path finding. Again, once you move close enough to a street segment, a snap point is displayed and the address is displayed on the top right corner. You can type the 'x' character to toggle the street as a barrier. Upon a mouse click, the closest node is selected as a starting node. Next, move the mouse to another node and click, and a path is displayed. The last selected node is now the starting node, click again and a path is calculated and displayed. Type 'C' to clear the resulting path. Like usual the source code is here. Have fun.PS: People have reported some drawing issues :-( that have been resolved if you use FP10.

Glad u like it - yes it can be applied to regular street networks - but (there is always a but :-) u have to take into account the street direction - so every edge has to be a single direction edge - like that u can control the impedance - not difficult - just work.

This is gr8 but(as you said there is always but:) ) i tried to load a street network dataset with the Application but it could not be loaded i think i need to know the mapping between the shape file you are using and the network dataset as i tried to open the shape file you use in the sample but it give me error . Thx in advance

About Me

BigData Advocate - Senior Software Architect at Esri - In addition to being part of the dev team, I travel the globe assisting customers implement BigData solutions with ArcGIS server - Cloudera Certified Hadoop Developer and HBase Specialist - When not coding, you will find me road biking in the middle of winter - went out the other day and was 8F - stay warm :-)