Skip to content

Instantly share code, notes, and snippets.

@kungfoo
Created June 4, 2010 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kungfoo/425248 to your computer and use it in GitHub Desktop.
Save kungfoo/425248 to your computer and use it in GitHub Desktop.
package ch.hsr.geohash;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import ch.hsr.geohash.queries.GeoHashCircleQuery;
import ch.hsr.geohash.queries.GeoHashQuery;
public class GeoHashCircleQueryTest {
private WGS84Point center = new WGS84Point(10.00254, 76.30627);;
@Test
public void checkJerryDonSample1() {
checkRadiusSearchHashes(1000, "t9y2bk" );
}
@Test
public void testJerryDonSample2() {
checkRadiusSearchHashes(1500, "t9y2bh", "t9y2bs", "t9yb2b0", "t9yb2b8");
}
@Test
public void testJerryDonSample3() {
checkRadiusSearchHashes(2500, "t9y2b");
}
private void checkRadiusSearchHashes(int radius, String ... string) {
GeoHashQuery query = new GeoHashCircleQuery(center, radius);
List<String> expectedHashes = Arrays.asList(string);
List<GeoHash> searchHashes = query.getSearchHashes();
assertEquals(expectedHashes.size(), searchHashes.size());
for(GeoHash hash : searchHashes){
if(! expectedHashes.contains(hash.toBase32())){
fail("Hash " + hash + " not found in list of expected hashes");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment