latitude-longitude

Calculate the area of a polygon with latitude and longitude

断了今生、忘了曾经 提交于 2019-11-29 05:22:09
I have this code, written using this: source1 and this: source 2 public static double CalculatePolygonArea(IList<GpsLocation> coordinates) { double area = 0; if (coordinates.Count > 2) { for (var i = 0; i < coordinates.Count-1; i++) { GpsLocation p1, p2; p1 = coordinates[i]; p2 = coordinates[i + 1]; area += ToRad(p2.Longitude - p1.Longitude) * (2 + Math.Sin(ToRad(p1.Latitude)) + Math.Sin(ToRad(p2.Latitude))); area = area * R * R / 2; } } return Math.Abs(area); } Here is my test code: [Fact] public void GpsPolygonAreaTest() { var poly = new List<GpsLocation>(); var p1 = new GpsLocation(0, 0);

locationManager.getLastKnownLocation() return null

只谈情不闲聊 提交于 2019-11-29 03:32:48
i dont understand why locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); return the location null. I gave all permission but its reutning null . if (isGPSEnabled) { if (location == null) { locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); Log.d("GPS", "GPS Enabled"); if (locationManager != null) { location = locationManager .getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); } } } } I had this exact

transform longitude latitude into meters

夙愿已清 提交于 2019-11-29 03:21:56
问题 I need a function that maps gps positions to x/y values like this: getXYpos(GeoPoint relativeNullPoint, GeoPoint p){ deltaLatitude=p.latitude-relativeNullPoint.latitude; deltaLongitude=p.longitude-relativeNullPoint.longitude; ... resultX=latitude (or west to east) distance in meters from p to relativeNullPoint resultY=longitude (or south to north) distance in meters from p to relativeNullPoint } i have seen some implementations of "distance of two geoPoints" but they all just calculate the

How can I get latitude, longitude from x, y on a Mercator map (JPEG)?

六月ゝ 毕业季﹏ 提交于 2019-11-29 03:07:47
问题 I have a Mercator projection map as a JPEG and I would like to know how to relate a given x, y coordinate to its latitude and longitude. I've looked at the Gudermannian function but I honestly don't understand how to take that function and apply it. Namely, what input is it expecting? The implementation I found (JavaScript) seems to take a range between -PI and PI, but what's the correlation between my y-value in pixels and that range? Also, I found this function which takes a latitude and

How do I calculate the distance between two points of latitude and longitude? [duplicate]

自作多情 提交于 2019-11-29 02:56:24
问题 This question already has an answer here: Distance between two coordinates with CoreLocation 4 answers i have latitude and longitude of particular place and i want to calculate the distance so how can i calculate it? 回答1: CLLocation *location1 = [[CLLocation alloc] initWithLatitude:lat1 longitude:long1]; CLLocation *location2 = [[CLLocation alloc] initWithLatitude:lat2 longitude:long2]; NSLog(@"Distance i meters: %f", [location1 distanceFromLocation:location2]); [location1 release];

Format latitude and longitude axis labels in ggplot

会有一股神秘感。 提交于 2019-11-29 02:54:02
问题 I have a ggplot map, for example: library(ggmap) ggmap(get_map()) I'd like the axis labels to be automatically labeled as N-S / W-E: in the above case, for example, instead of lon -95.4 it should show 95.4°E. I have tried to mess with the scales package and using scale_x_continuous and scale_y_continuous labels and breaks options, but I have not managed to make it work. It would be awesome to have a scale_y_latitude and scale_x_longitude . EDIT: Thanks to @Jaap 's answer I got to the

Get results from mysql based on latitude longitude

隐身守侯 提交于 2019-11-29 01:52:20
I have a mysql Database and 2 tables let's say clients and schools. Now each table has columns latitude and longitude. And I need do make a SELECT for example from second table where schools are in a given radius of one record from first table. Calculations should be made based on latitude and longitude. PS: I am using PHP. You can calculate a distance using a Spherical law of cosines : SELECT DEGREES(ACOS(SIN(RADIANS(clients.latitude)) * SIN(RADIANS(schools.latitude)) + COS(RADIANS(clients.latitude)) * COS(RADIANS(schools.latitude)) * COS(RADIANS(clients.longitude – schools.longitude)))) * 60

How to get E6 format of Longitude Latitude for Google Maps on Android

烈酒焚心 提交于 2019-11-29 01:12:42
问题 how do i find out the SPECIFIC E6 values of longitude latitude of a location. For example, i googled for long-lat of Asuncion, the capital city of Paraguay. It returns me: The latitude and longitude of Asuncion, Paraguay is 25°16' S, 57°40 W Now how do i convert THIS format of long-lat into E6 format of long-lat which android understands? What exactly IS THIS E6 thing? [p.s. i also googled for E6 long-lat of Asuncion....... with no luck] 回答1: So it's a two step process - thanks to hooked82's

PHP: Format Latitude and Longitude with degrees, minuets and seconds

那年仲夏 提交于 2019-11-29 00:15:47
How can I convert this: 26.72773551940918 Into something like this: 22°12'42"N The trick here is that the coordinates are, actually Latitude and Longitude, I just need to format them correctly. You can find functions to do that here <?php function DMStoDEC($deg,$min,$sec) { // Converts DMS ( Degrees / minutes / seconds ) // to decimal format longitude / latitude return $deg+((($min*60)+($sec))/3600); } function DECtoDMS($dec) { // Converts decimal longitude / latitude to DMS // ( Degrees / minutes / seconds ) // This is the piece of code which may appear to // be inefficient, but to avoid

Get PHP Timezone Name from Latitude and Longitude? [duplicate]

不羁岁月 提交于 2019-11-29 00:13:55
问题 This question already has answers here : How to get a time zone from a location using latitude and longitude coordinates? (14 answers) Closed 2 years ago . Is there a way get the timezone of a user by their latitude and longitude? And not just the offset, but the actual timezone they're in. Essentially, I'm searching for the polar opposite of DateTimeZone::getLocation which returns the latitude and longitude for a certain timezone. 回答1: Geonames should do the job nicely: http://www.geonames