latitude-longitude

Find closest 10 cities with MySQL using latitude and longitude?

旧街凉风 提交于 2019-12-10 19:37:56
问题 I have searched the Web a lot to find the solution for my problem but I still can't figure it out. I have a very simple database with id, city name, latitude, longitude and city_info. When someone enters a city page a would like to show the 10 nearby cities. How can I calculate this with MySQL and return it with PHP? I have seen a lot of suggestions on this website, however none of these work somehow. What I tried without success. I do not get any results. <?php $slatitude = 43.2141341;

Queries to find places within a given lat/lng

≡放荡痞女 提交于 2019-12-10 13:39:32
问题 So I'm trying to display lists of places within a range of the given lat/lng. I have no problem with this: Places within one mile (list of places...) Using something like SELECT * FROM places WHERE lat < $latmax AND lat > $latmin AND lng < $lngmax AND lng > $lngmin But then I want to list places within two miles, BUT not within one mile -- that is, I don't want to repeat the results from the first query. Here's one version of what I've tried: $milesperdegree = 0.868976242 / 60.0 * 1.2; // 1

Determine distance from coastline in Matlab

让人想犯罪 __ 提交于 2019-12-10 13:27:07
问题 In MATLAB, I have an array of latitude and longitude pairs that represents locations in the United States. I need to determine the distance to the nearest coastline. I think MATLAB has a built in database of lat/lon points of the United States. How do I access it and use it? Also any suggestions on how to efficiently determine the distance? Update : Follow-up question : Determine center of bins when using meshm 回答1: load coast; axesm('mercator'); plotm(lat,long) There are other datasets in

how to calculate all points(longitude,latitude) within a given radius from given point (longitude,latitude)?

自闭症网瘾萝莉.ら 提交于 2019-12-10 11:59:15
问题 I have a given point (longitude,latitude) and I want to get all the points ranges that comes lets say 5 miles radius in given point? 回答1: I'm just guessing here, but I think you'll need to find a different approach. If you're trying to do something like Foursquare, Google Maps, etc where it finds places within a 5-mile radius of your current location, I think you'll find that these services don't calculate all the points in that radius and then match them up to places at those points. There

calculate distance with 2 geo points

微笑、不失礼 提交于 2019-12-10 11:47:31
问题 I want to calculate the distance between 2 geo points, for now between my school and my house. The distance should be close 1200 meter. I get these values back which don't make sense. 104.247784180256 35.017200205306295 (if I reverse lat and lon) Google maps says: 51.987957 is N 5.911305 is O is 51.987957 lat or lon? According to my documentation of where I get the GPS signal from it should be latitude but I have my doubt about that. float R = 6371; // km // 104.247784180256 float lat1 = 5

Calculate the center of latitude and longitude coordinates

拥有回忆 提交于 2019-12-10 09:40:26
问题 I'm looking for a elegant solution that calculates the center between several latitude-longitude coordinates (for example, to simply center a map to the center of a google-maps polygon). Table: locations : id | city | latitude | longitude ----------------------------------------------- 1 | Berlin | 52.524268 | 13.406290 ----------------------------------------------- 2 | London | 51.508129 | -0.1280050 ----------------------------------------------- 3 | Hamburg | 53.551084 | 9.9936817 -------

Calculate the distance from point A to line segment using Lat /Lon

佐手、 提交于 2019-12-10 09:34:12
问题 I am working on an Android app that uses the GPS. I would like to know if there is a way I can throw out GPS Location data if the "new location" (point C) is too far away from line segment AB. I am using the Point to Line Segment formula found on Wikipedia. So far, the code I have is returning NaN when I try to use Latitude and Longitude coordinates. private void verifyGPSLocation(Location start, Location end, Location current){ final double errorValue = 0.0000216; double normalLength = Math

Longitude / Latitude to quaternion

谁说胖子不能爱 提交于 2019-12-10 04:52:47
问题 I've got a longitude and latitude and want to convert this to a quaternion and wondering how I can do this? I want to use this, because I've got an app which projects the earth on a sphere and I want to rotate from one location to another one. Best! 回答1: There's a way to go about this without using matrices or vectors, similar to this numpy implementation. We can think of longitude/latitude as two quaternion rotations composed together. Let's work with a Z-up right-handed coordinate system.

Google heatmap plotting with wrong gradient based on weight

谁说胖子不能爱 提交于 2019-12-09 23:24:08
问题 I was having some problem with Google Heatmap. The result that I am getting as such: The following as the code for me to populate the array for heatmap, I declared the heatmapData as global array so that I can be used in some other function: var heatmapData = []; function addForecastMarker(marker){ // code to plot marker here heatmapData.push({location: new google.maps.LatLng(marker['lat'], marker['lng']), weight: marker['total'].toFixed(2)}); } When I tried to print out the above data to

rough estimate of the time offset from GMT from latitude longitude

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-09 14:51:23
问题 Is there a way to estimate the offset from GMT (or time zone) from a latitude/longitude? I've seen geonames, but this would need to work long term and we don't really want to rely on a web service. It'd just be used for determining whether to display "today" or "tonight" when giving information to various users so it wouldn't need to be too accurate (an hour or two off wouldn't be bad). 回答1: offset = direction * longitude * 24 / 360 where direction is 1 for east, -1 for west, and longitude is