Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.util.Log;

public class Main {
    private static String TAG = "HotspotDbHelper";
    private static double LATLON_SECTION = 0.044966;

    public static int getGeoHash(double lat, double lng) {
        if (lat == 0.0 && lng == 0.0)
            return 0;

        double latHash = (lat + 180) / LATLON_SECTION;
        double lngHash = (lng + 180) / LATLON_SECTION;
        int latHashRounded = (int) Math.round(latHash);
        int lngHashRounded = (int) Math.round(lngHash);

        int hash = latHashRounded * 10000 + lngHashRounded;

        Log.d(TAG, "HotspotDbHelper getGeoHash for lat: " + lat + " lon: " + lng + " is " + hash);
        return hash;
    }
}