use of com.github.davidmoten.geo.Coverage in project geo by davidmoten.
the class DatabaseTest method displayQueryTimes.
private void displayQueryTimes(Connection con, long now, int length) throws SQLException {
System.out.println("--------------------------------------");
Coverage coverage = GeoHash.coverBoundingBox(-5, 136, -6, 138, length);
System.out.println("numHashes=" + coverage.getHashes().size());
StringBuilder s = new StringBuilder();
for (String hash : coverage.getHashes()) {
if (s.length() > 1)
s.append(" or ");
s.append("geohash" + hash.length() + "='" + hash + "'");
}
StringBuilder s2 = new StringBuilder();
for (String hash : coverage.getHashes()) {
if (s2.length() > 1)
s2.append(" or ");
s2.append("geohash12 like '" + hash + "%'");
}
String sql2 = "select name,lat,lon from report where time >= ? and time <? and (" + s + ")";
processQuery(now, con, sql2);
String sql3 = "select name,lat,lon from report where time >= ? and time <? and (" + s2 + ")";
System.out.println("using like:");
processQuery(now, con, sql3);
}
use of com.github.davidmoten.geo.Coverage in project geo by davidmoten.
the class Geomem method find.
/**
* Returns as an {@link Iterable} the results of a search within the
* bounding box given and where start <=time < finish.
*
* @param topLeftLat
* latitude of top left point (north west)
* @param topLeftLon
* longitude of top left point (north west)
* @param bottomRightLat
* latitude of bottom right point (south east)
* @param bottomRightLon
* longitude of bottom right point (south east)
* @param start
* start time inclusive
* @param finish
* finish time exclusive
* @return info records
*/
public Iterable<Info<T, R>> find(double topLeftLat, double topLeftLon, double bottomRightLat, double bottomRightLon, long start, long finish) {
Coverage cover = GeoHash.coverBoundingBox(topLeftLat, topLeftLon, bottomRightLat, bottomRightLon);
Iterable<Info<T, R>> it = Collections.emptyList();
for (String hash : cover.getHashes()) {
it = Iterables.concat(it, find(topLeftLat, topLeftLon, bottomRightLat, bottomRightLon, start, finish, hash));
}
return it;
}
Aggregations