I want to get all cities close to my actual geolocalisation (by GPS) in a X radius. A good example is the app Tinder. The user select the value of radius in KM and the app gets all the cities close to his geolocalisation inside the selected radius.
I want to calculate the radius and get all cities within by javascript or PHP.
An illustration:
You can download a database of all US cities, with their states and latitude/longitude, then query the database based on current GPS info. Just google search for a DB, they are about 30 meg, so make sure your queries are optimized.
Here is a db that should work...
https://www.maxmind.com/en/free-world-cities-database
If you can find a geospacial database it would perform better (not sure if linked one is or not). I have used a non geospacial one and it was fine though.
Related
I want to try and draw a trail that follows each marker I have that is updated live from a MySQL database table with GeoJson every 8 seconds.
I have tried drawing a polyline from the Start Position to Current Position of each of the GeoJson features/leaflet markers but that won't work of course since it only takes into account the start and current position and not any turns of direction changes made underway.
I am trying to make something that draws a direct trail behind each of the markers based on the previous positions. My GPS trackers submit latitude and longitude to a database table every minute or so. My idea is that I could maybe create a new table and just make it submit every latitude and longitude from all GPS trackers and draw LineStrings for each marker based on that maybe?
But I think that wouldn't really be a good efficient way to do it since I would have multiple GPS trackers submitting latitude and longitude every minute and the GPS trackers would be moving very slow so it is very minor changes each time (if even any at all since the slow moment speed and only 4 decimal precision in the latitude and longitude there could even be cases without any changes in the submitted data)
Does anybody here have an idea for an efficient way to draw a live updating trail behind each marker from GeoJson? :)
Think of the database tables as "persistent storage" for all the data.
Have your client, when it receives more info (every 8 seconds and/or every minute) do the following:
SELECT the last location from the``Current` table, which has 1 row per item being tracked.
Draw on the canvas (or wherever) the line from where it was (step 1) to where it now is (incoming data).
INSERT the new location into the History table.
UPDATE the current location in a table that has just the Current locations of all your vehicles (or polar bears or dolphins or snails).
Four decimal places won't work for snails. It has a resolution of about 16 meters or 52 feet. See Representation choices . Four may not be sufficient for vehicles; some of the time it will erroneously show the vehicle in a ditch or on the wrong side of a highway -- simply because 4 decimal places is not enough.
I don't know about GeoJson; I'm looking at what can be done with MySQL and HTML5's "Canvas".
On a slow machine 100 changes per second should be possible. So, if you don't have a thousand things moving around, I don't see a performance problem.
The push-me, pull-me Problem
Since a web page is stateless and the data is flowing the wrong direction, it will be difficult to design a setup where the path is continually showing on the screen, and being updated periodically (every 8 seconds).
One approach is to 'push' the data into the database (as discussed above). Then have the web page that is showing the trail poll the database to see if there is something need to display.
Such "polling" would be done via AJAX that is called every, say, second. The reply would include all new location changes. The web page would paint new line segments based on whatever data was returned (zero or more kangaroos, as appropriate).
I am having a data set of say 10000 GPS points. I need to find GPS points depending on how frequently the area is visited by using the GPS data set I have. I am looking for a solution either by using google maps or by using mongoDB, but unable to find any clue how should I achieve this. Can anyone help me regarding this?
sample data = [{18.5204303,73.8567437},{18.520457, 73.856697},{18.520400, 73.856800},{18.520156, 73.857092},{18.519879, 73.857561}]
Out of the given data set first three point are near to each other.
So, whenever I will ask for frequently visited area from the given data set I should get result as [{18.5204303,73.8567437},{18.520457, 73.856697},{18.520400, 73.856800},{18.520156, 73.857092}]
I got the solution using google heatmap. I just passed array of gps points to heatmap and the heatmap displayed it in proportion of frequent access to the locations. That is what I was trying to achieve
I'm new here and looking for help. I tried almost everything including nodejs, embedden js and others ..
There is very cool feature of google maps js: It can show the nearest available streetview with given location.
http://bloggerbotu.com/Githadi/nearestimage.html?lat=37.952866&lng=34.151230
Here is an example. I edited it a little.
When we put our lat and long values even doesn't have street view, it finds the nearest location and shows us an image.
And you could see there is a small textbox on the upper right side of the page that shows the location of available streetviews. I need this value.
But they all in browser side. I tried with nodejs but not succesfful. I can't do that.
You'll see there is some kind of processing of queries and when you click somewhere like mountain or out of road, the process starts and find the nearest available location again. And textbox changes with
document.getElementById("koordinat").value = data.location.latLng;
I don't need images or map markers etc. All I want is, when I give lat and long, a small php script or node based server script that returns me the nearest streetview-available coordinates.
Thanks
Is there any Javascript API that does not display the entire world map and later allows to zoom and click to individual countries, but instead just displays the country we are interested and allows region-level clicks? In other words, I am looking for an API similar to JVectorMap but this does not have comprehensive support for all countries and it does not show street-level view when zooming further deep into state/city level. I hope my requirements are clear. If I am interested only in let's say England's map, I want the map to show just England but allow state and city-level clicks with street-level or near street-level views at the lowest level as an optional feature (not too many details at the lowest-level). Google Maps, jHERE etc. seem to show the entire world map and allow to zoom-in, which is not something I want.
thanks,
Paddy
If you only want the street maps for one country to be visible, you could download the Open Street Map data into a PostGIS database for that country and that country only, and generate tiles. There are several tutorials on how to download data and make tiles, e.g. http://switch2osm.org/serving-tiles/manually-building-a-tile-server/
I'm using CakePHP/mysql to build my app and I'm trying to get a list of cities within a given mile radius around an address both supplied by the user. So far I have a list of all US cities in a database with the long/lat. I also am using a CakePHP plugin to get the long/lat of all addresses inserted into the database.
Now how do I do the last part? I'm new to the google maps api but it looks like there is a limit on how many queries I make a day. The only way I can think to do it is to check the distance from the address and compare it to every city in the database and if it is within the given radius then they are selected. It seems like this would be way too database intensive and I would pass my query quotas in one go.
Any ideas?
It sounds like you're trying to determine if a given point (city) is within a circle centered on a specific lat/lon. Here's a similar question.
Run a loop over each city and see if it satisfies the following condition:
if ( (x-center_x)2 + (y-center_y)2 <= radius2 )
If this is too slow, you could turn it into a lookup based on rounding the lat/lon. The more values you precompute, the closer to exact you can get.