Showing posts with label MapQuest. Show all posts
Showing posts with label MapQuest. Show all posts

Tuesday, 1 August 2017

TrafficControl: Mapping Position on Track to Coordinates

TrafficControl is supposed to present the train positions on the tracks in real-time. To achieve this, the trains needs to get their locations, when providing their location on the tracks.

I'll implement a function in tcTrack that will work in three steps:
  1. In the track constructor, the coordinates are already provided. A Haversine formula will calculate the accumulated distances between the first waypoint of the track and all following waypoints.
    1. Import coordinates to constructor - DONE
    2. Implement Haversine function - DONE
    3. Use Haversine function to generate list of accumulated distances - DONE
  2. A function will take an integer as input parameter (position on track in meters). The function will return the last waypoint that is before the input position. - DONE
  3. Another function that interpolates to provide the accurate coordinate.


The result can be seen in the video below. The color of the tracks are: Green (empty), Yellow (occupied). The color of the border of the station circles are: Green (empty), Yellow (populated) and Red (full).



After upgrading Qt from 5.7 to 5.9.1, that came two weeks ago, the map issue with tiles is resolved.
The road map forQt 5.9 canbe found on the web site.

Thursday, 23 March 2017

TrafficControl: Four Commits and a Bug

I pushed the code with the dynamic QML stations, code cleanup and fixes to the KML parser to the CuteTrains GitHub repo  in four commits (one of them since I'm still on the Git learning curve and two of them are simply bad planning from my side). 

The fixes to the KML parser (trackStationConnector.py) considers the direction of the track in the file name. 

The code cleanup is an attempt to follow the C coding style according to https://www.gnu.org/prep/standards/html_node/Writing-C.html

When running three trains on the bigger network file (Skane_Coordinates.txt), I notice that the trains doesn't follow the travel plans. I know that the train::move part of the program is a mess and needs refactoring. 

I'll focus on debugging the issue with the trains inability to follow the travel plan in future blog posts.

Saturday, 11 March 2017

TrafficControl: Resuming...


When resuming the project, I've seen that the tile issue with tiles that aren't shown seem to be unstable. Some zoom levels work but not others. Qt Blog has addressed that issue and discussed solutions to the issue:
http://blog.qt.io/blog/2017/03/09/provisioning-openstreetmap-providers-in-qtlocation/

I also installed Microsoft Visual Studio, and used that compiler. No missing DLLs and much quicker compilation. I assume the reason is that MSVC is more adopted to the Windows 10 workstation that I'm using than MinGW that I used before.

The next blog post will describe a breakthrough in TrafficControl!

Tuesday, 26 July 2016

TrafficControl: MapQuest/OSM needs API Key

For the last time, I've been working experimenting with maps using QML and MapQuest/Open Street Maps. The application logic is still in C++ but the map handling is in QML, where the map is rendered. Unfortunately, API keys are needed for applications using OSM  since July 11th this year.

The consequence of this is that the map tiles applications get from OSM contains no useful map information:
Before, the center of Malmö was shown


The issue is also affecting the default Qt examples, and there is a bug report addressing this issue: https://bugreports.qt.io/browse/QTBUG-5459. Currently, it isn't clear how to add that API key in Qt/QML programs. For the Qt version 5.6, API keys aren't supported, but hopefully the Qt developers may provide a patch for that.

I assume that OSM has introduced this API key requirement to reduce traffic to the servers and to have some control of which software packages that can access the servers. Providing servers and storage for maps are very resource demanding.

For my program, I can still investigate the implementation, where I'm trying to figure out how to add tracks to QML dynamically when the program reads the KML file. I am considering some C++ model that is interacting with a QML view.

Update:
The lesson of this is that software depending on external parties needs to be revised on a regular basis, since there will be changes to external interfaces.