Calculate distance between two points including country borders info - google-maps

I am trying to find any solution that can calculate distance between point A and point B BUT including information about country's border.. I checked Google Maps and Bing Maps APIs - both of them don't provide such features..
Any suggestion? Thank you in advance

First you can create a database of country boundaries. Country boundaries are easy to find online. Here is one source: http://www.diva-gis.org/Data
You can upload these into SQL 2008/2012 or Azure (express version is free) using the Shp2Sql tool here: http://www.sharpgis.net/page/Shape2SQL.aspx
Then using Bing Maps you can calculate a route and get the route point's. You can use the route points to create a LineString object and do an intersection test against the country data to get all the countries boundaries that line passes through. Then you can go through each resulting country and crop the line to the borders of the country. With the crop line you can then measure it's length. All of this can be done with the spatial tools in SQL. Here are some useful links.
http://msdn.microsoft.com/en-us/library/ff701713.aspx
http://technet.microsoft.com/en-us/library/bb933901.aspx
http://technet.microsoft.com/en-us/library/bb933962.aspx
http://technet.microsoft.com/en-us/library/bb933895.aspx

Related

Is it possible to use OSRM in order to calculate routing into a building?

I would to know :
If we save in OSRM server a dataset of points stored from a GPS tracker into a building (a flat one) : is it possible to request the server in order to find the shortest way from a point to another ?
The aim would be to help customers/employees find their way into a place which has not any standard GIS data like roads, street and so on (like a stadium used during a convention, a zoo, an amusement park, and so on)
Point clouds are not a valid data format for the OSRM. You will need OSM data. So you could use your GPS points to create a OSM Map of your building. For more infos about indoor mapping see: https://wiki.openstreetmap.org/wiki/Indoor_Mapping

Possible to create a map with route planning via multiple preset locations depending on distance?

So, Imagine I have a car planning to travel some distance.
Is it possible to create a map on my web page, putting planned route (from location to location), my consumption of my car and it would tell me where I could fill it up again. But only via my preset location.
Could I use some of the API in google maps to create this?
Something similar to this would be Tesla route planner: https://www.tesla.com/en_CA/trips?redirect=no
You can start off with Maps JavaScript API's Directions Service which calculates directions between locations that also contains the distance and duration for the route.
Also check out the example here: https://developers.google.com/maps/documentation/javascript/examples/directions-simple
Hope this helps!

Plot coordinates near a given set of coordinates on Google maps

This is the scenario...
I have a set of lat/long data stored in a db table[id, lat, long, location]. I'm using geo-location to get a user's current physical location(lat and long). When this user accesses the app, allows his location to be shared, I want to get those coordinates that are around his current coordinates, and plot them on a Google Map.
How can this be done?
Example: I have the coordinates for hotels in a city stored in my DB table. When a user visits this city and accesses my app, I want to get from my DB and plot on map only those coordinates that are around him in a certain radius.
Note: I'm using PHP for server side stuff.
Any help is appreciated!
You describe a store locator: finding POIs within a radius around a particular point. A store locator finds POIs within a radius around a location. The details in Google's example are different (you find the centre point via browser geolocation and have a fairly small radius) but the principle is exactly the same.
Google's article: developers.google.com/maps/articles/phpsqlajax_v3

Google maps - find cities close to my route

I would like to get a list of all cities I might pass on my way between point A and point B
Input -
point A as origin
point B as destination
Output:
Route between point A and point B (that's obvious)
AND
list of cities / towns / places that are closer than X miles to my route.
I would like to present the user a list of possible waypoints to consider (points of interest, historic sites, parks, etc)
Any ideas how to do that?
I believe you'd need to do this in a two-stage process:
The first step would be to calculate a polyline representing the route between A and B (as you say, that's obvious). You can do this using the Bing Maps REST (http://msdn.microsoft.com/en-us/library/ff701717.aspx) or SOAP (http://msdn.microsoft.com/en-us/library/cc966826.aspx) routing services, for example.
When you request the route from either of these services, make sure you specify that you want the full route path to be included in the results (rpo paramter for REST or RoutePathType.Points parameter for SOAP). This will give you an array of all the points that are used to construct the routepath - otherwise you'll just get a summary of itinerary points (i.e. only those points on the route at which you need to do something - change roads etc.)
Once you've got the array of points, step two is to determine all those locations that lie within distance x of the path drawn between these points. While there are many webservices that allow you to query for places lying within x distance of an individual point (including the Bing Maps search service and the geonames findNearby service, for example), I'm not aware of any webservices that provide this functionality, so you'll have to provide it yourself.
One way of doing so would be to use SQL Server 2008 or SQL Server Azure, loaded up with the geonames allCountries data dump from http://download.geonames.org/export/dump/. You could then construct a LineString geometry from the points in your routepath, and query the list of places in the database with a query such as:
SELECT * FROM allCountries WHERE Location.STDistance(#RoutePath) <= 1000;
Johannes Kebeck posted an example using this approach based on the Bing SOAP Route service and SQL Azure, which you can find here: http://jkebeck.wordpress.com/2010/06/26/find-near-route-for-bing-maps-powered-by-sql-azure-spatial/

How to find a closest street

I'm reading through Google Maps API documentation and I wonder if such a think is possible:
I specify the point (by coords)
I search for all roads, and junctions around the node (say in 1km radius)
I get parameters for the streets around (polyline coords)
Is it reachable, or google do not share that data?
Thanks in advance
Rafal
I can image writing up a little script that generates a bunch of random points within a 1km radius and then performs directions services via Google Maps API to obtain all possible routes and thus streets within a 1km radius. However, this is problematic since it is kinda against the Google Maps TOS of displaying this information only on a map within a website and not extracting data for you personal use as this would be.
A better approach would be looking into utilizing Open Street Map data where you can download street data from a specific viewport. If buying street network data is an option, you can go to a commercial outlet such as NAVTEQ or PTV which post-processes NAVTEQ data to a format for use in the transport modeling software package you mention on your blog.