Rumus Menentukan Jarak Antara Dua Koordinat GPS

Just my fivety cents :) . Sedang berkutat dengan geografi nih :p . Penggunaan GPS (Global Position System) perlahan semakin berkembang. Kebetulan saya sedang mencari cara untuk menentukan jarak antara dua titik koordinta (latitude dan longitude) ke tempta tujuan.

Ini Rumus dasarnya :

double EARTH_RADIUS = 6367.45;

double latitude;
double longitude;

double lat2;
double lon2;

double deltalat = lat2 - latitude;
double deltalon = lon2 - longitude;

double a = Math.sin(deltalat / 2) * Math.sin(deltalat / 2) + Math.cos(latitude) * Math.cos(lat2) * Math.sin(deltalon / 2) * Math.sin(deltalon / 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
double distance = EARTH_RADIUS*c;

Selamat mencoba :)

Reblog this post [with Zemanta]

About Achmad Fachrie

Achmad Fachrie
Loves to "ngoprek" (research), do something new, travelling, reading and writing. Have speciality in web development (PHP, MySQL), mobile development (android), have some experiences in linux open source activist. Beside as web developer, he also experience as instructor, IT auditor, and now his daily activities as IT Independent Developer and Researcher :)

4 comments

  1. mas, klo bisa ada versi lengkapnya dan ada skrinsutnyah…
    jadi kita ada gambaran jadinya seperti apa..

    hehe… maklum masi belajar mas…
    :D

  2. Achmad Fachrie

    Pak ruslan. Wah, lain kali saya buat ya. :)

    Terima kasih

  3. bagaimana ya menghitung jarak 2 koordinat dg jalur laut (kapal)..?

  4. mas ahmad, ajarin dong agar + pinter nich bila tahu jalur laut kita he….he..
    terima kasih

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current day month ye@r *

More in Aktivitas, Linux / FOSS (37 of 190 articles)