latitude-longitude

Calculate the center of latitude and longitude coordinates

£可爱£侵袭症+ 提交于 2019-12-05 17:52:13
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 ----------------------------------------------- 4 | Amsterdam | 52.370215 | 4.8951678 ------------------------

How get the current latitud and longitud without use getLastKnownLocation method in Android?

烈酒焚心 提交于 2019-12-05 16:00:37
I am trying to get the current position of the phone, for this I use the GPSTracker tutorial , the problem is always use the method getLastKnownLocation and return older position. if (isNetworkEnabled) { locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); Log.d("Network", "Network"); if (locationManager != null) { location = locationManager .getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); } } } // if GPS

Calculate distance between points using Long and Lat in SQL SERVER

梦想的初衷 提交于 2019-12-05 14:06:55
I am using the below destination [BMAnalytics].[dbo].[EUACTIVESTORES] And it has columns [Store No] [Lat] [Long] Can I use these columns to self Join the [Store No] so I have each combination of Store to Store listed in two columns, called 'Source' & 'Target' And then in a third column is it possible to calculate the distance between the two? I have used the below previously but this only works for one single point to point, DECLARE @source geography = 'POINT(0 51.5)' DECLARE @target geography = 'POINT(-3 56)' SELECT (@source.STDistance(@target))/1000 Ideally, i'd like the distance from each

location (lat long) using facebook api

纵然是瞬间 提交于 2019-12-05 13:56:01
Is there a way to get the location of a user in (latitude and longitude format) using facebook api?? I am able to get the location name and other attributes but not the lat long of the place. Is there any API for the same in javascript. If you have the user's basic info, one of the fields is location "location": { "id": "104146386288393", "name": "Newton, Massachusetts" }, You can make another query using the id of the location to return JSON containing lat/lon of the city, e.g. { "id": "104146386288393", "name": "Newton, Massachusetts", "picture": "http://external.ak.fbcdn.net/safe_image.php

How to add lines of longitude and latitude on a map using ggplot2?

和自甴很熟 提交于 2019-12-05 13:44:15
I am now plotting the map of Canada using ggplot2 . Because the default projection method is "aea"(Albers Equal Area), so the longitude and latitude are straight lines on the map. I wonder how I can display the longitude and latitude in the form of "110W, 100W, 90W" and "50N, 60N, 70N" on the map. They should be curves. Thanks a lot. The arcgis shapfile is downloaded from https://www.arcgis.com/home/item.html?id=dcbcdf86939548af81efbd2d732336db library(ggplot2) library(rgdal) countries<-readOGR("Canada.shp", layer="Canada") ggplot()+geom_polygon(data=countries,aes(x=long,y=lat,group=group)

Python lat/long midpoint calculation gives wrong result when longitude > 90

好久不见. 提交于 2019-12-05 12:50:18
I have a problem with a short function to calculate the midpoint of a line when given the latitude and longitude of the points at each end. To put it simply, it works correctly when the longitude is greater than -90 degrees or less than 90 degrees. For the other half of the planet, it provides a somewhat random result. The code is a python conversion of javascript provided at http://www.movable-type.co.uk/scripts/latlong.html , and appears to conform to the corrected versions here and here . When comparing with the two stackoverflow versions, I'll admit I don't code in C# or Java, but I can't

Parsing latitude and longitude with Ruby

流过昼夜 提交于 2019-12-05 12:04:54
I need to parse some user submitted strings containing latitudes and longitudes, under Ruby. The result should be given in a double Example: 08º 04' 49'' 09º 13' 12'' Result: 8.080278 9.22 I've looked to both Geokit and GeoRuby but haven't found a solution. Any hint? "08° 04' 49'' 09° 13' 12''".gsub(/(\d+)° (\d+)' (\d+)''/) do $1.to_f + $2.to_f/60 + $3.to_f/3600 end #=> "8.08027777777778 9.22" Edit: or to get the result as an array of floats: "08° 04' 49'' 09° 13' 12''".scan(/(\d+)° (\d+)' (\d+)''/).map do |d,m,s| d.to_f + m.to_f/60 + s.to_f/3600 end #=> [8.08027777777778, 9.22] How about

How Do I Calculate the Area of a Polygon in a MySQL Database When the Polygon's Points are Lat Longs?

痞子三分冷 提交于 2019-12-05 11:37:59
How do I calculate the area of a polygon stored in a MySql database? The polygons' points are lat longs. So, degrees and minutes seem to be causing a problem. I've tried: SELECT AREA( my_polygon ) FROM `my_table` WHERE name = 'Newport' Because, the points are lat longs, I get weird results. (I'm not able to switch to Postgre). Is there a way to do this in MySQL? I'd like to get the results in sq. meters or sq. km or sq. miles-- any of these would be fine. You've got to transform those lats and lons into a more appropriate coordinate system. Since the earth is a sphere, you're talking about

Flickr API for location based images

余生颓废 提交于 2019-12-05 10:11:05
I want to get images of cities when city name is entered in search field in iOS. I am using flickr API but whenever I enter any longitude and latitude values, I only get returned an empty array. What should I do. I am using this URL: http://api.flickr.com/services/rest/?method=flickr.photos.geo.photosForLocation&api_key=e3d577010e5979a2ad2a22714abd901e&lat=40.6700&lon=73.9400&format=json&nojsoncallback=1&auth_token=72157638668602974-e1a3a3aa1e6d3dd8&api_sig=a0233b016c863b1662aeb21a664c351a Please tell me what should I do. any help appreciated I suspect that you are seeking too precise a match

Longitude / Latitude to quaternion

北慕城南 提交于 2019-12-05 09:23:33
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! 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. Let's call longitude φ and latitude θ, and the point represented by the two as (φ, θ). For visualization,