How to convert an address to a latitude/longitude?

Google has a geocoding API which seems to work pretty well for most of the locations that they have Google Maps data for. http://googlemapsapi.blogspot.com/2006/06/geocoding-at-last.html They provide online geocoding (via JavaScript): http://code.google.com/apis/maps/documentation/services.html#Geocoding Or backend geocoding (via an HTTP request): http://code.google.com/apis/maps/documentation/services.html#Geocoding_Direct The data is usually the same used by Google Maps itself. (note that there are some … Read more

How can I measure distance and create a bounding box based on two latitude+longitude points in Java?

Here is a Java implementation of Haversine formula. I use this in a project to calculate distance in miles between lat/longs. public static double distFrom(double lat1, double lng1, double lat2, double lng2) { double earthRadius = 3958.75; // miles (or 6371.0 kilometers) double dLat = Math.toRadians(lat2-lat1); double dLng = Math.toRadians(lng2-lng1); double sindLat = Math.sin(dLat / … Read more

How, exactly does HTML5’s GeoLocation work?

The data sent by Firefox to Google is for all visible access points, public or private. For each access point detected, it sends the following data to https://www.google.com/loc/json: “mac_address”: “01-23-45-67-89-ab”, “signal_strength”: 8, “age”: 0, “SSID”: “MyAccessPoint” where mac_address is the mac address of the WiFi node. signal_strength is current signal strength measured in dBm. age … Read more

Timezone lookup from latitude longitude [closed]

I looked fairly deeply into this question for a project I am working on. GeoNames.org and EarthTools.com are both good options for many situations but with the following serious flaws: GeoNames.org finds the time zone by searching for the nearest point in their database that contains a time zone field. This often leads to the … Read more

How do I Geocode 20 addresses without receiving an OVER_QUERY_LIMIT response?

No, there is not really any other way : if you have many locations and want to display them on a map, the best solution is to : fetch the latitude+longitude, using the geocoder, when a location is created store those in your database, alongside the address and use those stored latitude+longitude when you want … Read more

Why use the SQL Server 2008 geography data type?

If you plan on doing any spatial computation, EF 5.0 allows LINQ Expressions like: private Facility GetNearestFacilityToJobsite(DbGeography jobsite) { var q1 = from f in context.Facilities let distance = f.Geocode.Distance(jobsite) where distance < 500 * 1609.344 orderby distance select f; return q1.FirstOrDefault(); } Then there is a very good reason to use Geography. Explanation of … Read more

How to calculate the bounding box for a given lat/lng location?

I suggest to approximate locally the Earth surface as a sphere with radius given by the WGS84 ellipsoid at the given latitude. I suspect that the exact computation of latMin and latMax would require elliptic functions and would not yield an appreciable increase in accuracy (WGS84 is itself an approximation). My implementation follows (It’s written … Read more

Google Maps: how to get country, state/province/region, city given a lat/long value?

What you are looking for is called reverse geocoding. Google provides a server-side reverse geocoding service through the Google Geocoding API, which you should be able to use for your project. This is how a response to the following request would look like: http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=false Response: { “status”: “OK”, “results”: [ { “types”: [ “street_address” ], … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)