datafu.pig.geo
Class HaversineDistInMiles
java.lang.Object
org.apache.pig.EvalFunc<T>
datafu.pig.util.SimpleEvalFunc<java.lang.Double>
datafu.pig.geo.HaversineDistInMiles
public class HaversineDistInMiles
- extends SimpleEvalFunc<java.lang.Double>
Computes the distance (in miles) between two latitude-longitude pairs
using the Haversine formula.
Example:
-- input is a TSV of two latitude and longitude pairs
input = LOAD 'input' AS (lat1 : double, long1 : double, lat2 : double, long2 : double);
output = FOREACH input GENERATE datafu.pig.geo.HaversineDistInMiles(lat1, long1, lat2, long2) as distance;
Fields inherited from class org.apache.pig.EvalFunc |
log, pigLogger, reporter, returnType |
Method Summary |
java.lang.Double |
call(java.lang.Double lat1,
java.lang.Double lng1,
java.lang.Double lat2,
java.lang.Double lng2)
|
org.apache.pig.impl.logicalLayer.schema.Schema |
outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
Override outputSchema so we can verify the input schema at pig compile time, instead of runtime |
Methods inherited from class org.apache.pig.EvalFunc |
finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getSchemaName, isAsynchronous, progress, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EARTH_RADIUS
public static final double EARTH_RADIUS
- See Also:
- Constant Field Values
HaversineDistInMiles
public HaversineDistInMiles()
call
public java.lang.Double call(java.lang.Double lat1,
java.lang.Double lng1,
java.lang.Double lat2,
java.lang.Double lng2)
outputSchema
public org.apache.pig.impl.logicalLayer.schema.Schema outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
- Description copied from class:
SimpleEvalFunc
- Override outputSchema so we can verify the input schema at pig compile time, instead of runtime
- Overrides:
outputSchema
in class SimpleEvalFunc<java.lang.Double>
- Parameters:
input
- input schema
- Returns:
- call to super.outputSchema in case schema was defined elsewhere
Matthew Hayes, Sam Shah