public static String encode(double latitude, double longitude){
		double[] lat_interval = {-90.0 ,  90.0};
		double[] lon_interval = {-180.0, 180.0};
			
		StringBuilder geohash = new StringBuilder();
		boolean is_even = true;
		int bit = 0, ch = 0;
		
		while(geohash.length() < precision){
			double mid = 0.0;
			if(is_even){
				mid = (lon_interval[0] + lon_interval[1]) / 2;
				if (longitude > mid){
					ch |= bits[bit];
					lon_interval[0] = mid;
				} else {
					lon_interval[1] = mid;
				}
				
			} else {
				mid = (lat_interval[0] + lat_interval[1]) / 2;
				if(latitude > mid){
					ch |= bits[bit];
					lat_interval[0] = mid;
				} else {
					lat_interval[1] = mid;
				}
			}
			
			is_even = is_even ? false : true;
			
			if (bit  < 4){
				bit ++;
			} else {
				geohash.append(_base32[ch]);
				bit =0;
				ch = 0;
			}
		}
		
		return geohash.toString();
	}