Creating Road Junctions from OpenStreetMap XML file (.osm file)

I have a project which requires me to calculate traffic volume counts at road junctions. I have traffic volume counts along a main street between side streets from local municipalities/cities.
I need to create Road Junctions from Street data downloaded from OpenStreetMap and merge the traffic volume counts and calculate the traffic counts at the road junctions.

I have download the .osm file and examined the XML file, I can find Node_id data which identifies coordinates as lat/lng, the .osm file contains way_id elements which are the street data coordinates identified by the Node_Ids. However when I tried to match the map streets with the XML file, I could find some BUT NOT ALL of the side streets connected to the main street. But the side streets are joined to the main street on the map. How does the program which generates the map know which side street is connected to another street (I could not find the common Node_ids, which suggest that a side street is connected to the main streets )

For example:

Node_id Lat/Lng


N1 Lat1, Lng1
N2 Lat2, Lng2
N3 Lat3, Lng3
N4 Lat4, Lng4
N5 Lat5, Lng5
N6 Lat6, Lng6

Etc, etc

Way_id Lat/Lng Comments (Way_id’s with M are Main streets, SS are Side Streets)


M1 N1,N2,N3,N4 - there may be multiple Node_ids representing the street (ie. indicating the beginning or end of the street, a traffic light, a bend in the road, a Node_Id indicating a Side Street
- a tag with the street name
SS1 N2,N6 - this would indicate that Side Street 1 has a common node with M1 at Node_Id N2, ie. it intersects and is therefore a junction
SS2 N7,N8 - NOTE: in some cases the SS2 woud show up on the map as a Side Street of M1, BUT I COULD NOT FIND THE MATCHING NODE N7 or N8 in the list of nodes of M1

Can anyone explain how the streets are generated in OpenStreetMap if there are no matching Node_Ids to connect the Main Streets and Side Streets eeven though they show up as Junctions on OpenStreetMap?

Also is there a program which allows me to Parse the XML file and extract the Street Names identified by Way_id and the Node_Id’s of other streets that are connected to the Street. I would put all these into an SQL database, I would create the GeoHash code for the Beginning and Ending of the each of the streets. By looping through all the Way_id elements I could then search the SQL database and look for all streets that have a GeoHash code either at the beginning or end of the street which is less than a specified tolerance (ie. less than a few meters) from the Way_Id. I would then assume that this is a road junction, then by taking the average traffic counts of all the streets (ie. sum all traffic from the streets at the junction and divide by the number of streets) I arrive at the traffic count at the junction.

I have had a look at HTML Parsing programs but they are much more that what I need. Any suggestions would be welcome…

Thank you in advance

RTham

Hi RTham,

still intested in an answer?