Finn fem fel? - Lab1

CREATE OR REPLACE FUNCTION CALCDISTFINAL(lat1 FLOAT(24), long1 FLOAT(24), lat2 FLOAT(24), long2 FLOAT(24)) RETURNS FLOAT(24) as $$ DECLARE earthRadius FLOAT(24); lat1Rad FLOAT(24); lat2Rad FLOAT(24); long1Rad FLOAT(24); long2Rad FLOAT(24); alfa FLOAT(24); distance FLOAT(24); partArg FLOAT(24); BEGIN -- Conversions lat1Rad := RADIANS(lat1); lat2Rad := RADIANS(lat2); long1Rad := RADIANS(long1); long2Rad := RADIANS(long2); -- Constants earthRadius := 6371; -- km -- Variables partArg := COS(long1Rad-long2Rad); alfa := ACOS(COS(lat1Rad)*COS(lat2Rad)*COS(partArg)); distance := earthRadius * alfa; RETURN distance; END; $$ LANGUAGE plpgsql;

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.