Q:

Mapinfo - Compare Road Direction

I have two layers of Road Networks. How do I compare the difference in road direction between the two layers - both are polylines?

A:

Here is some pseudo-code on how you can do this.
For each road segment:

Find same road segment in the other dataset
Check if the distance from start point in road segment to start point in road segment from other dataset is within a tolerance 
If it is the road segments have the same direction

You can achieve this using a small MapBasic script, and you can also do it using a SQL statement like the one below.
If you want to use the SQL, you might need to create some work on one of your datasets for it to be used in the SQL.
I'd recommend:

add two float columns for coordinates from the first point
creating a small buffer around the centroid to use this to find the matching record in the other dataset

The query could look like this:
Select *
  From Roads1, Roads2Buffer
  Where Roads1 Intersects Roads2Buffer.obj
  And Distance(ObjectNodeX(Roads1.obj,1,1), ObjectNodeY(Roads1.obj,1,1), Roads2Buffer.StartNodeX, Roads2Buffer.StartNodeY, "m") < 10

I join the two tables using the Intersects operator on the road segment from the first table and the buffer on the centroid in the other table.
I also specify that the distance between the start nodes in the two tables should be less than 10 meters.
The query finds the road segments that do have the same direction. If you are looking for those that aren't, use "> 10".
You can, of course, change the distance tolerance and you also need to decide on a reasonable buffer size to make sure you make it intersect.

