This is what you need : http://esri.github.io/gis-tools-for-hadoop/ , a GIS tools for Hadoop toolkit. The Hive Spatial component of this spatial framework adds geometric user-defined functions(UDFs) to Hive. These UDFs (e.g. distance between two points) are built on top of the Esri Geometry API and are modeled on the ST_Geometry OGC compliant geometry type.
Otherwise, you can simply compute the distance using the Haversine formula :
dlon = lon2 - lon1
dlat = lat2 - lat1
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2( sqrt(a), sqrt(1-a) )
d = R * c (where R is the radius of the Earth and it's equal to 6378137 meters).
Raju Thapa- I want integration of Google Maps API in Hive for calculating the driving mode distance.
@Mehdi Boukhechba- Thanks for the reply.I think that Haversine formula will give you Aerial or spatial distance between two points.Actually i need to get the "driving mode" distance between two points using Google Api's.
I have used below mentioned query and formula in hive to find out the spatial distance but result was given me some kms variation when i compared with Google Maps API result.
In this case you need to create your own User Defined Function (UDF).
Create a Java class for the UDF which makes an HTTP call to Google Maps Distance Matrix API and returns the distance in the desired mode (e.g. https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters)
Package your Java class into a JAR file
Go to Hive CLI, add your JAR, and verify your JARs is in the Hive CLI classpath
CREATE TEMPORARY FUNCTION in Hive which points to your Java class
Use it in Hive SQL and have fun!
Here is a tutorial on how to do these steps: https://dzone.com/articles/writing-custom-hive-udf-andudaf
Mehdi Boukhechba-- Thanks for the wonderful suggestion...Seems like it will work with UDF concept.I am writing the UDF in python.Will share the code as well if it works fine.