Google Maps Distance Matrix Traffic Assumptions - google-distancematrix-api

I am trying to figure out exactly how the distance matrix API processes traffic for driving. Currently, I am using the advanced version of the API by specifying a date and time of departure. I use the gmapsdistance package in R, and specify "None" for the traffic_model (my understanding is this is equivalent to reading in "" to the API).
What is the difference between this, and running the API on the basic version (i.e. not specifying a date and time for departure)? Some results were different when comparing the two options, but I cannot pin down why.
Thank you!

Related

Music21 and D3.js for music feature extraction and visualization?

I am looking for suggestions on what tools could be used for the following scenarios about music feature extraction and visualization (on my Mac):
identify and group notes in a score (from different voices/instruments) that sound concurrently (even if they are attacked in different time offsets, though sound at some point together due to different duration lengths); then connect them graphically (e.g. on a score representation, with a line connecting them)
identify melodic and accompanying parts (assigned to different voices/instruments, perhaps interchangeably within the same voice/instrument)
extract initial tonality and following modulations; then map all extracted tonalities on a scale based on the circle of 5ths (where 0 is the initial tonality, -1 is one 5th lower, +1 one 5th higher, etc.)
I have been thinking of using music21 (the music works I am interested in are part of its corpus), but I am not sure if this is the right way to go. Are there also other tools (e.g. jSymbolic2??) that could help?
And what about visualization? Could the above scenarios be visually "solved" within music21 or would I need an additional tool, like D3.js (which I have briefly used in the past)?
If you would have an advice on any of the above scenarios, that would help me a lot! Thanks, Ilias

How to dispatch and auto-allocate requests to the nearest drivers

First of all, I must say that I was very hesitant to post the following as I am afraid from getting down votes. However, I've spent days thinking about a solution and I haven't found one. My last hope is to get some answers in this post.
The Problem
Say that you have a large database of drivers connected in real-time to your backend, while you are fetching their lat/long each 5 seconds and posting it back to the backend so you update in real-time a driver's location. Let's suppose that we want to benefit form drivers and their positions to let a particular user find the closer connected driver to it (like in UBER,Lyft, etc..).
The question:
How is it possible to dispatch request to these drivers ? (I want you to share with me only you thoughts and ideas).
What you are looking is called "GeoSpatial search".
If you are looking for algorithms to implement then take a look at Nearest Neighbour Search
The most famous algorithm is k-Nearest Neighbours algorithm.
If you are only interested in using an existing implementation and build your application on top of it then there are existing databases & search applications which provide capability of GeoSpatial search.
Check Apache Solr which provides Geospatial search capabilities. https://cwiki.apache.org/confluence/display/solr/Spatial+Search
you just need to feed your drivers live location into this and query with current location of user. Solr will take care of finding the nearest drivers and you will get a search result with your matching criteria.
You can use this as a starting point to build your app with location based searches. In pratice, Uber, Lyft and other major services have their own in-house application with custom implementations.

Cache Geospatial calculations or calculate on the fly?

I'm a developer on a service vehicle dispatching web app. It's written in .Net 4+, MVC4, using SQL server.
There are 2000+ locations stored in the database as geography data-types. Assuming we send resources from location A to location B, the drive time / distance etc... needs to be displayed at one point. If I calculate the distance with SQL Server's STDistance it will only give me the "As the crow flies" distance. So the system will need to hit a geo spatial service like bing, Google, or ESRI and get the actual drive time or suggested routes. the problem is this is a core function and will happen ALOT.
Should I pre-populate a lookup table with pre-calculated distances or average drive times? The down side is even without adding more locations that's 4Million records to search every time the information is needed.
On top of this, most times the destination is not one of our stored geospatial coordinates and can instead be an address or long/lat point anywhere on the continent which makes pre-calculating impossible.
I'm trying to avoid performance issues having to hit some geoservies endpoint constantly.
Any suggestions on how best to approach this?
-thanks!
Having looked at these problems before, you are unlikely to be able to store them all.
it is usually against almost all of the routing providers TOS for you to cache the results. You can sometimes negotiate this ability but it costs alot.
Given that there is not a fixed set of points you are searching against, doing one calculation gives you little information for the next calculation.
I would say maybe you can store the route for pair once they have been selected so you can show that route again if needed. Once the transaction is done I would remove the route from your DB.
If you really want to cache all this or have more control over it you can use PGRouting (with Postgresql) and then obtain street data. though I doubt it is worth your effort.

What is the proper way to use the radius parameter in the Google Places API?

I am using the Google Places API to retrieve all the POI (Places of Interest) around a the current location, it works ok but I have noticed that whatever the value of the radius is, I always get the same number of results (~ 20). As a result, if I give a radius that is too big, I don't necessarily get the nearest POIs. If I reduce the amount of the radius to be small enough, I will retrieve those nearest places again (from experimentation, I have noticed that 100 meters is a proper value) but that means that I will not get any POIs beyond 100 meters which is not quite what I want.
My question is: is there any way by which I can get all the POIs (with no limitations) within a certain radius.
Thank you!
The Google Places API always returns 20 results by design, selecting the 20 results that best fit the criteria you define in your request. The Developer's Guide / Docs don't explicitly cite that number anywhere that I have seen. I learned about the limit watching the Autocomplete Demo & Places API Demo & Discussion Video, given by Paul Saxman, a Developer Advocate at Google and Marcelo Camelo, Google's Technical Lead for the Places API.
The entire video is worth watching, but more specific to your question, if you set the playback timer at about 11:50, Marcelo Camelo is contrasting the Autocomplete tool versus the general Places API, and that's the portion of the video where he mentions the 20 result limit. He mentions 20 as the standard result count several times.
There are many other good Places API and Google Maps videos linked to that area on YouTube as well.
As mentioned on the Google Places Issue Tracker here: http://code.google.com/p/gmaps-api-issues/issues/detail?id=3425
We are restricted by our data provider licenses to enable apps to display no more than 20 places results at a time. Consequently we are not able to increase this limit at this time.
It does sound like you are however trying to return results that are closest to a specified location, this is now possible by using the 'rankby=distance' parameter instead of 'radius' in your request.
e.g.
https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&rankby=distance&types=food&name=harbour&sensor=false&key=YOUR_API_KEY
Try google.maps.places.RankBy.DISTANCE; as default is google.maps.places.RankBy.PROMINENCE;
An easy example of this is shown Here
(Chrome only)

Find highest spot with Google Earth API?

I needed to find out the highest point of a region.
However when I iterate through all the points isn't efficient enough for a my CPU.
So does Google Earth API provide any relevant approach ?
Thanks !
Did not see Google Earth API provides anything about this, but you may add elevation as a parameter to reduce results, and give it an increment until the result's count is acceptable.
Since this point doesn't change often, I would just use a constant.
'Mount Everest (WGS84)
highest_lat = 27.988056
highest_lon = 86.925278
Without seeing any code it is impossible to say where the overhead is. However, in general, you should pass your multiple calls to the api using the google.earth.executeBatch method.
https://developers.google.com/earth/documentation/reference/google_earth_namespace#ab26414915202d39cad12bcd5bd99e739
This method efficiently executes an arbitrary, user-defined function minimizing the amount of overhead incurred during cross-process communication between the web browser and Google Earth Plugin.
Here is a working example
http://earth-api-samples.googlecode.com/svn/trunk/examples/batch.html

Resources