Skip to content

Commit 8c50c9a

Browse files
author
tabish
committed
NodeDistance is now using the great circle distance using postgres packages cube and earthdistance;
create extension cube; create extension earthdistance; CREATE VIEW site_distances AS SELECT x.site as "site1", x.id as "site1id", y.site as "site2", y.id as "site2id", point(x.longitude, x.latitude) <@> point(y.longitude, y.latitude) AS "distance" FROM vivo_aggregated.site_location AS x, vivo_aggregated.site_location AS y;
1 parent 2469cc9 commit 8c50c9a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/edu/uiowa/slis/graphtaglib/filters/NodeDistance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ public void filterNodes(Graph theGraph, String selectedNode, int radius) {
6060
// Get co-authors for node and add edge to graph only if that
6161
// neighbor is within our radius
6262
PreparedStatement theStmt = conn
63-
.prepareStatement("select candidate.* from vivo_aggregated.site_loc as candidate, vivo_aggregated.site_loc as center where center.id=? and circle(center.position,(?/111.0)) @> candidate.position");
63+
.prepareStatement("select site2id, site2 from vivo_aggregated.site_distances where site_distances.site1id=? and site_distances.distance<=?");
6464

6565
theStmt.setInt(1, Integer.parseInt(selectedNode));
6666
theStmt.setInt(2, radius);
6767
logger.debug("Query:: " + theStmt.toString());
6868
ResultSet rs = theStmt.executeQuery();
6969
while (rs.next()) {
70-
logger.trace(rs.getString(1) + ' ' + rs.getString(2) + ' ' + rs.getString(3));
70+
logger.trace(rs.getString(1) + ' ' + rs.getString(2));
7171
sites += rs.getString(1) + " ";
7272
sites_hash.put(rs.getInt(1), rs.getString(2));
7373
}

0 commit comments

Comments
 (0)