/** * A bunch of geohashes for testing neighbors, contains and other stuff. * @return array */ public static function geohashProvider() { $geohashes = array(array('s00000000000'), array('y00000000000'), array('f00000000000'), array('q00000000000'), array('600000000000'), array('zzzzzzzzzzzz'), array('bpbpbpbpbpbp'), array('pbpbpbpbpbpb'), array('000000000000'), array('drt2zm8ej9eg'), array('dqcjqcr8yqxd'), array('6ey6wh6t808q'), array('u26q7454172n'), array('w78buqdznjj0')); // add some random tests for ($i = 0; $i < 3; $i++) { $geohashes[] = array(geohash::encode(new geopoint(mt_rand(-90000, 90000) / 1000, mt_rand(-180000, 180000) / 1000, 12))); } foreach ($geohashes as $test) { $geohashes[] = array(substr($test[0], 0, 1)); // test single character geohashes $geohashes[] = array(substr($test[0], 0, 2)); // test two character geohashes $geohashes[] = array(substr($test[0], 0, 5)); // test five character geohashes $geohashes[] = array(substr($test[0], 0, 8)); // test eight character geohashes } return $geohashes; }
/** * Convenience method to convert this geopoint to a geohash. * @see geohash::encode * @param int $precision * @return geohash */ public function geohash($precision = 8) { return geohash::encode($this, $precision); }