Author Topic: Intersecting routes on the HB  (Read 34416 times)

0 Members and 1 Guest are viewing this topic.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2856
  • Last Login:Yesterday at 09:42:37 pm
Intersecting routes on the HB
« on: May 19, 2017, 01:49:50 pm »
The highway browser on the tmtest site has a first attempt at linking to intersecting routes.  The links are in the "infowindow" that pops up when you click on a waypoint.  Any other route that includes a point with identical latitude and longitude as that waypoint will be listed.  I decided to put the links here rather than right in the list of waypoints because I didn't want to clutter up the lists, I don't want to mess around with the CSS that formats those tables, and it was a little easier to code this way.  The big problem at the moment is that the extra DB queries (one per waypoint) really slow things down.  For small routes, it's not too bad, but for long ones, the delay is unacceptably long.  And this is after I made some changes to the queries to make them about 4-5 times faster than my original attempt.  Unfortunately, my database expertise is pretty limited, and I don't know what else to try.  I'm guessing that I'll need to make some changes to the table structure itself to allow these queries to be more efficient, or to store the information about intersecting routes in some other way.

Offline michih

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 4849
  • Last Login:November 20, 2024, 11:21:09 am
Re: Intersecting routes on the HB
« Reply #1 on: May 19, 2017, 02:00:03 pm »
I made a test:
http://tm.teresco.org/hb/index.php?units=km&u=terescoj&r=deu.a003 (loading time: ~1s)
http://tmtest.teresco.org/hb/index.php?units=km&u=terescoj&r=deu.a003 (loading time: ~90s)

Do you check all waypoints or the waypoints of the region only?

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2856
  • Last Login:Yesterday at 09:42:37 pm
Re: Intersecting routes on the HB
« Reply #2 on: May 19, 2017, 02:28:58 pm »
Yes, very slow.  There's one DB query per non-hidden waypoint in the route being displayed.  Given the current structure of the DB, I don't know a way to avoid making that many queries.  Doesn't mean there isn't one.

Offline compdude787

  • TM Collaborator
  • Sr. Member
  • *****
  • Posts: 298
  • Gender: Male
  • Last Login:November 08, 2024, 12:26:51 pm
Re: Intersecting routes on the HB
« Reply #3 on: May 19, 2017, 02:55:51 pm »
Yeah, we might want to wait on implementing this until we can figure out how to make the loading time be faster. Otherwise people are going to get extremely frustrated at how slow it's going.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2856
  • Last Login:Yesterday at 09:42:37 pm
Re: Intersecting routes on the HB
« Reply #4 on: May 19, 2017, 04:15:06 pm »
Fortunately, Google knows SQL tricks even if I don't.  Try it now.  It's fast!

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2856
  • Last Login:Yesterday at 09:42:37 pm
Re: Intersecting routes on the HB
« Reply #5 on: May 19, 2017, 04:24:45 pm »
At this point, I'm interested in hearing mostly if I broke anything.  I'd like to push this functionality out as-is to start if existing functionality still appears to work.  If you prefer a different presentation of this information (such as in the waypoint table, more similar to how CHM's old HB did these), let me know.

Before reporting a case where an intersecting highway does not show up, please make sure it's not a data problem.  I know we still have NMPs out there, and this code looks for exact matches.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2856
  • Last Login:Yesterday at 09:42:37 pm
Re: Intersecting routes on the HB
« Reply #6 on: May 19, 2017, 04:43:53 pm »
I see that my latest "fix" now makes it so the list in the table and the infowindow strings don't line up properly.  So clicking on an entry in the table brings up the wrong one.  Surely fixable, but I'm tied up the rest of the afternoon and much of the evening.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2856
  • Last Login:Yesterday at 09:42:37 pm
Re: Intersecting routes on the HB
« Reply #7 on: May 19, 2017, 06:25:30 pm »
Sorry to carry on a conversation with myself on this..  I had a minute to look for the error with the waypoint table and infowindows not lining up and I have made a fix.  Looks good now.  Please test away!

Offline mapcat

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 1767
  • Last Login:Yesterday at 09:47:09 pm
Re: Intersecting routes on the HB
« Reply #8 on: May 19, 2017, 10:03:56 pm »
No problems to report here. Working great!
Clinched:

Offline yakra

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 4422
  • Last Login:November 11, 2024, 12:50:03 pm
  • I like C++
Re: Intersecting routes on the HB
« Reply #9 on: May 20, 2017, 02:30:49 am »
I decided to put the links here rather than right in the list of waypoints because I didn't want to clutter up the lists, I don't want to mess around with the CSS that formats those tables, and it was a little easier to code this way.
If you prefer a different presentation of this information (such as in the waypoint table, more similar to how CHM's old HB did these), let me know.
I prefer to have this info just as you've done it. I've actually wished it was listed in the InfoWindow since back in the CHM days.Thanks for doing this!
Sri Syadasti Syadavaktavya Syadasti Syannasti Syadasti Cavaktavyasca Syadasti Syannasti Syadavatavyasca Syadasti Syannasti Syadavaktavyasca

Offline compdude787

  • TM Collaborator
  • Sr. Member
  • *****
  • Posts: 298
  • Gender: Male
  • Last Login:November 08, 2024, 12:26:51 pm
Re: Intersecting routes on the HB
« Reply #10 on: May 20, 2017, 02:35:35 am »
Oh yeah, it's working great now! I'm glad you were easily able to improve the loading times.

Offline michih

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 4849
  • Last Login:November 20, 2024, 11:21:09 am
Re: Intersecting routes on the HB
« Reply #11 on: May 20, 2017, 03:37:58 am »
Cool feature, thanks :) Loading time seems to be the same with or without this feature now.
I really like the idea of displaying Intersecting/Concurrent Routes in the info window and I'm even happy that it's NOT displayed in the table like yakra said

We sometimes move wps by exactly 0.000001° to break concurrencies but the route is still intersecting. Is it possible to include these routes?

If I click on the intersecting route, the HB is loaded as usual. Is it possible to center the map with the last waypoint and zoom in with the same zoom level and with the same map style which was selected before? That means, I would see exactly the same map but just the highlighted route is changed. I could directly proceed browsing at the point I left the previous route.

I found a bug on tmtest which might be caused by this improvement or anything else but I think it's worth to be reported:
http://tm.teresco.org/hb/index.php?units=km&u=terescoj&r=deu.e50 (E50 shield is resized fine)
http://tmtest.teresco.org/hb/index.php?units=km&u=terescoj&r=deu.e50 (E50 shield is not resized correctly)
I've checked other shields and it seems to work fine but anything seems to be different on tmtest server... maybe just an outdated "template_eure.svg" file?

Edit: Shields are outdated on tmtest only. Maybe you could update it to avoid strange behavior and minimize annoying "bug" reports


More strange things:
1. Open http://tmtest.teresco.org/hb/?units=km&u=terescoj&r=bel.e17
2. Click on the last "BEL/FRA" wp, info window displays "waypoint 4" which is wrong
3. The next wp windows display 3 - 4 - 3 - 3 -3 - 2 -2 - 3 --> wrong
4. Click on the last "BEL/FRA" wp again.
5. Click on "BEL A14" --> Fine
6. Click on "FRA A22 (Tourcoing)" --> Fine
7. Click on "FRA E17" --> wp table is loaded correct but the route is not loaded on the map!


Just a note you might ignore right now but I'd like to say that some countries have intersecting routes which are not directly connected, especially countries with tolled motorways like France or Spain. There are often trumpet interchanges. The waypoints are off by more than just 0.000001°. I don't think that the intersecting feature could cover this use-case. For that reason, my Open Highway Browser for specific routes from the map feature is still as important as before.
« Last Edit: May 20, 2017, 04:39:58 am by michih »

Offline mapcat

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 1767
  • Last Login:Yesterday at 09:47:09 pm
Re: Intersecting routes on the HB
« Reply #12 on: May 20, 2017, 07:58:01 am »
We sometimes move wps by exactly 0.000001° to break concurrencies but the route is still intersecting. Is it possible to include these routes?
I would prefer that we NOT include routes that are close but don't intersect.

Quote
2. Click on the last "BEL/FRA" wp, info window displays "waypoint 4" which is wrong
3. The next wp windows display 3 - 4 - 3 - 3 -3 - 2 -2 - 3 --> wrong
To me it looks like "waypoint X" means that X routes use that point.
Clinched:

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2856
  • Last Login:Yesterday at 09:42:37 pm
Re: Intersecting routes on the HB
« Reply #13 on: May 20, 2017, 08:54:58 am »
We sometimes move wps by exactly 0.000001° to break concurrencies but the route is still intersecting. Is it possible to include these routes?

I'd argue that those should not be included, since the concurrencies were intentionally broken.  If there's an intersection, then maybe those should be lined up and concurrencies should be broken with a shaping point instead.

If I click on the intersecting route, the HB is loaded as usual. Is it possible to center the map with the last waypoint and zoom in with the same zoom level and with the same map style which was selected before? That means, I would see exactly the same map but just the highlighted route is changed. I could directly proceed browsing at the point I left the previous route.

Sounds like a nice idea.  We should note it as a GitHub issue as a feature request for the future.

Edit: Shields are outdated on tmtest only. Maybe you could update it to avoid strange behavior and minimize annoying "bug" reports[/color]

I've updated them now, but don't do it regularly on tmtest since it makes the code update take about 10x longer than it does when I omit shields.

More strange things:
1. Open http://tmtest.teresco.org/hb/?units=km&u=terescoj&r=bel.e17
2. Click on the last "BEL/FRA" wp, info window displays "waypoint 4" which is wrong
3. The next wp windows display 3 - 4 - 3 - 3 -3 - 2 -2 - 3 --> wrong

Fixed this.  Lesson: be careful blindly using i as a loop index variable.  It might be already used for something else.

7. Click on "FRA E17" --> wp table is loaded correct but the route is not loaded on the map!

The problem here comes up because the City fields are in double quotes.  Any idea why?  That breaks my new JS code.

Just a note you might ignore right now but I'd like to say that some countries have intersecting routes which are not directly connected, especially countries with tolled motorways like France or Spain. There are often trumpet interchanges. The waypoints are off by more than just 0.000001°. I don't think that the intersecting feature could cover this use-case. For that reason, my Open Highway Browser for specific routes from the map feature is still as important as before.

For now, we'll stick with exactly intersecting only.  Related to this is an idea I've been kicking around for years now, mostly because of my academic use of the data, to have a non-clinchable "system" to indicate these kinds of things.  They'd become part of my graphs, but would not be displayed for TM.  But.. points connected in these cases could be exactly what you want here.

Thanks for all the testing and feedback.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2856
  • Last Login:Yesterday at 09:42:37 pm
Re: Intersecting routes on the HB
« Reply #14 on: May 20, 2017, 09:05:17 am »
7. Click on "FRA E17" --> wp table is loaded correct but the route is not loaded on the map!

The problem here comes up because the City fields are in double quotes.  Any idea why?  That breaks my new JS code.

Looking into this, it seems over 500 routes, all in Europe, have their city fields enclosed in double quotes.  Before I code a workaround in the intersecting routes code or remove those possibly extraneous quotes from the csv files, I want to make sure they're not there for some Good Reason that I'm not aware of.