latitude-longitude

How to calculate distance from lat/long in php?

人走茶凉 提交于 2019-11-27 02:19:07
问题 What I am trying to do is I have entries in the database which have a lat/long stored with them. I want to calculate the distance between users lat/long and entries lat/long (in DB). After that, I want to echo the ones with distance less than 500 meters. So far I am able to do this using foreach . <?php mysql_connect("localhost", "beepbee_kunwarh", "kunwar") or die('MySQL Error.'); mysql_select_db("beepbee_demotest") or die('MySQL Error.'); $Lat = $_REQUEST['Lat']; $long = $_REQUEST['long'];

Whats the fastest way to lookup big tables for points within radius MySQL (latitude longitude)

跟風遠走 提交于 2019-11-27 02:13:10
Currently I have a few tables with 100k+ rows. I am trying to lookup the data like follows. SELECT *, SQRT(POW(69.1 * (latitude - '49.1044302'), 2) + POW(69.1 * ('-122.801094' - longitude) * COS(latitude / 57.3), 2)) AS distance FROM stops HAVING distance < 5 ORDER BY distance limit 100 But currently this method slows with high load. Some queries are taking 20+ seconds to complete. If anyone knows any better ways to optimize this would be great. Well first of all if you have a lot of geospatial data, you should be using mysql's geospatial extensions rather than calculations like this. You can

Calculate distance given 2 points, latitude and longitude [duplicate]

大城市里の小女人 提交于 2019-11-27 01:08:54
Possible Duplicate: MySQL latitude and Longitude table setup I know this question has probably been asked many times, I've researched a lot and I need help with specific thing. Lets say I have a form and user enters longitude and latitude, and I have a database which has table containing longitudes and latitudes, how would I search for a point or points in that table that are within 15 miles of radius? You can use the formula that calculates distances between two points. For example: function get_distance($latitude1, $longitude1, $latitude2, $longitude2, $unit = 'Mi') { $theta = $longitude1 -

How can I quickly estimate the distance between two (latitude, longitude) points?

99封情书 提交于 2019-11-27 00:17:25
I want to be able to get a estimate of the distance between two (latitude, longitude) points. I want to undershoot, as this will be for A* graph search and I want it to be fast . The points will be at most 800 km apart. Aaron D The answers to Haversine Formula in Python (Bearing and Distance between two GPS points) provide Python implementations that answer your question. Using the implementation below I performed 100,000 iterations in less than 1 second on an older laptop. I think for your purposes this should be sufficient. However, you should profile anything before you optimize for

Receive a WOEID by Lat, Long with Yahoos API

筅森魡賤 提交于 2019-11-27 00:11:54
问题 i searched a while but found nothing, thats simular to my problem. i'm trying to use the YAHOO Weather API, for example: http://weather.yahooapis.com/forecastrss?w=4097 i don't know the WOEID in my case, but i got latitude and longitude points. so my question is: is there a way to get the WOEID of a place by using lat and long points? 回答1: This is now available through the recently released PlaceFinder API. Kudos to Yahoo! for providing yet another important piece of the Geo puzzle. 回答2:

How can I get city name from a latitude and longitude point?

大城市里の小女人 提交于 2019-11-26 23:55:28
Is there a way to get a city name from a latitude and longitude point using the google maps api for javascript? If so could I please see an example? smartcaveman This is called Reverse Geocoding Documentation from Google: http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding . Sample Call to Google's geocode Web Service: http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true&key=YOUR_KEY Here is a complete sample: <!DOCTYPE html> <html> <head> <title>Geolocation API with Google Maps API</title> <meta charset="UTF-8" /> </head> <body>

Converting longitude/latitude to X/Y coordinate

老子叫甜甜 提交于 2019-11-26 23:46:08
I created a map using Google Maps API that highlights all Minnesota counties. Basically, I created the county polygons using a set of longitudes/latitudes coordinates. Here's a screenshot of the generated map:- One of the user requirements is to be able to have a similar map as an image so that they can embed it in their PowerPoint/keynote slides. I couldn't find any useful Google Maps API that allows me to save my custom map the way it is (if you know a way, let me know), so I figure I should just draw it with Graphics2D in Java. After reading about the formulas to convert the longitude

Mapview getLatitudeSpan and getLongitudeSpan not working

北慕城南 提交于 2019-11-26 23:23:31
问题 Sometimes when trying to get the Latitude span or Longitude span of a mapview with getLatitudeSpan() and getLongitudeSpan() I get 0 and 360*1E6 respectively. This doesn't happen always but it is a problem, has anybody got this problem? Any workarounds? I tried using getProjection() too but I get the same problem. Here is the piece of code: MapView mapView = (MapView) findViewById(R.id.mapview); int lat = mapView.getLatitudeSpan(); // sometimes returns 0 int long = mapView.getLongitudeSpan();

What datatype to use when storing latitude and longitude data in SQL databases? [duplicate]

淺唱寂寞╮ 提交于 2019-11-26 23:22:29
This question already has an answer here: What is the ideal data type to use when storing latitude / longitude in a MySQL database? 20 answers When storing latitude or longitude data in an ANSI SQL compliant database, what datatype would be most appropriate? Should float be used, or decimal , or ...? I'm aware that Oracle, MySql, and SQL Server have added some special datatypes specifically for handling geo data, but I'm interested in how you would store the information in a "plain vanilla" SQL database. Decimal(9,6) If you're not used to precision and scale parameters, here's a format string

How to find my distance to a known location in JavaScript

折月煮酒 提交于 2019-11-26 22:37:35
问题 Using JavaScript in the browser, how can I determine the distance from my current location to another location for which I have the latitude and longitude? 回答1: If your code runs in a browser, you can use the HTML5 geolocation API: window.navigator.geolocation.getCurrentPosition(function(pos) { console.log(pos); var lat = pos.coords.latitude; var lon = pos.coords.longitude; }) Once you know the current position and the position of your "target", you can calculate the distance between them in