Recent

Author Topic: Free Method of calculating travel time with directions in Lazarus?  (Read 1987 times)

MrMaxMusterman

  • Guest
So im searching for an online service (API?) that can calculate my travel time from point a to b (by car over streets, not directly A to B over the air). It doesnt need to have live traffic included etc. but it should be free to use.
If theres anyone out there that knows a service like this (that is free) and could mabye help me to implement it into my program, feel free to leave a comment down below.

Thanks!

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Free Method of calculating travel time with directions in Lazarus?
« Reply #1 on: May 21, 2021, 09:44:23 pm »
Google Maps or, in general, any of the "maps" web out there (like OpenStreetMap) should do it nicely ... unless you want to know how much time you'll spend on the road from Alaska to Argentina :D
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

MrMaxMusterman

  • Guest
Re: Free Method of calculating travel time with directions in Lazarus?
« Reply #2 on: May 21, 2021, 09:48:00 pm »
Thanks for the answer. I already took a look at google maps and they do acutally offer something called "Distance Matrix API". The only problem with it is that the API key costs money.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: Free Method of calculating travel time with directions in Lazarus?
« Reply #3 on: May 21, 2021, 10:11:25 pm »
So im searching for an online service (API?) that can calculate my travel time from point a to b (by car over streets, not directly A to B over the air). It doesnt need to have live traffic included etc. but it should be free to use.
If theres anyone out there that knows a service like this (that is free) and could mabye help me to implement it into my program, feel free to leave a comment down below.

I believe you mean "I'd appreciate any comments".

As Lucamar says, you're unlikely to get anything free since somebody has to do a substantial amount of work determining how fast roads are in practice. You might get /distance/ so look at something like https://gis.stackexchange.com/questions/73766/how-to-create-an-od-road-distance-matrix-in-qgis but this would probably still involve substantial work... and you'd be unlikely to interface to it in Pascal.

Alternatively you might still be able to find a copy of pre-MS Autoroute somewhere for a one-off cost, I think that the full version of that had an API. But it would almost certainly lack much recent data.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: Free Method of calculating travel time with directions in Lazarus?
« Reply #4 on: May 21, 2021, 10:48:57 pm »
Thanks for the answer. I already took a look at google maps and they do acutally offer something called "Distance Matrix API". The only problem with it is that the API key costs money.

What's an API? https://xkcd.com/1481/ applies.

In this particular context, do you mean "getting the technical info costs money?" or "I need to buy account on their mainframe (for want of a better word) before I can do anything clever".

Elsewhere, somebody's suggested using Google Earth for this. However I don't recall Earth being aware of roads or similar entities which can constrain a route such that it's not a mere "as the crow flies" guess.

I'd add though that there's a great deal of useful stuff buried inside Earth: it was actually a fairly competent piece of GIS software before Google bought it up and bent it to their unholy will. And looked at from the other side, QGIS (as one specific example) can get overlays from Google and others... but again I don't know whether that has the concept of following roads.

MarkMLl


MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Free Method of calculating travel time with directions in Lazarus?
« Reply #5 on: May 22, 2021, 09:44:18 am »
You could download Open Street Maps data, host server your self locally (or use some of the public ones on the net), use TMapViewer for displaying maps, and use some of the tools/libs on the provided wiki page for routing, directions, and travel time calculations. If you don't find command line tool or REST API that suits you, then you will probably have to make headers for some of the C libs.

https://wiki.openstreetmap.org/wiki/Routing
https://wiki.openstreetmap.org/wiki/Simple_route_API

This could be your best bet:
https://wiki.openstreetmap.org/wiki/OpenRouteService
https://openrouteservice.org
https://github.com/ObuhovToplyvoApp/osm.routes

This might also be interesting:
https://github.com/search?q=osm+routing

Google directions API:
https://code.google.com/archive/p/delphimaps/
« Last Edit: May 22, 2021, 10:02:36 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018