Fun.Tuple3<String, String, ResultEnvelope.Which> key = new Fun.Tuple3<>( origin, dest, which); output.put(key, time);
for (Relationship targetClassification : targetClassifications) { final Node targetTaxonNode = targetClassification.getEndNode(); final Fun.Tuple3<Long, String, Long> interactionKey = new Fun.Tuple3<Long, String, Long>(sourceTaxon.getId(), interaction.getType().name(), targetTaxonNode.getId()); final Long distinctInteractions = taxonInteractions.get(interactionKey); taxonInteractions.put(interactionKey, distinctInteractions == null ? 1L : (distinctInteractions + 1L));
public Fun.Tuple3<Integer, Integer, Long>[] getTiles(int zIndex) { int minY = Integer.MAX_VALUE; int minX = Integer.MAX_VALUE; int maxY = Integer.MIN_VALUE; int maxX = Integer.MIN_VALUE; for(int i = 0; i < lons.length; i++) { int x = SpatialDataStore.getTileX(lons[i], zIndex); int y = SpatialDataStore.getTileY(lats[i], zIndex); if(x < minX) minX = x; if(x > maxX) maxX = x; if(y < minY) minY = y; if(y > maxY) maxY = y; } int tileCount = (maxX - minX + 1) * (maxY - minY + 1); Fun.Tuple3<Integer, Integer, Long>[] tiles = new Fun.Tuple3[tileCount]; int i = 0; for(int tileX = minX; tileX <= maxX; tileX++) { for(int tileY = minY; tileY <= maxY; tileY++) { tiles[i] = new Fun.Tuple3(tileX, tileY, this.id); i++; } } return tiles; }
public static void collectDistinctInteractions(StudyNode aStudy, Map<Fun.Tuple3<Long, String, String>, List<String>> studyOccAggregate) { final Iterable<Relationship> specimens = NodeUtil.getSpecimens(aStudy); for (Relationship specimen : specimens) { final Iterable<Relationship> interactions = specimen.getEndNode().getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j()); for (Relationship interaction : interactions) { if (!interaction.hasProperty(PropertyAndValueDictionary.INVERTED)) { final Node targetSpecimen = interaction.getEndNode(); final Node sourceSpecimen = interaction.getStartNode(); final String sourceTaxonExternalId = getExternalIdForTaxonOf(sourceSpecimen); final String targetTaxonExternalId = getExternalIdForTaxonOf(targetSpecimen); if (sourceTaxonExternalId != null && targetTaxonExternalId != null) { final Fun.Tuple3<Long, String, String> key = new Fun.Tuple3<Long, String, String>(aStudy.getNodeID(), sourceTaxonExternalId, interaction.getType().name()); List<String> targetTaxonExternalIds = studyOccAggregate.get(key); if (targetTaxonExternalIds == null) { targetTaxonExternalIds = new ArrayList<String>(); } if (!targetTaxonExternalIds.contains(targetTaxonExternalId)) { targetTaxonExternalIds.add(targetTaxonExternalId); } studyOccAggregate.put(key, targetTaxonExternalIds); } } } } }
/** * Insert the given way into the tile-based spatial index, based on its current node locations in the database. * If the way does not exist, this method does nothing (leaving any reference to the way in the index) because * it can't know anything about the location of a way that's already deleted. If the way object is not supplied * it will be looked up by its ID. */ public void indexWay(long wayId, Way way) { // We could also insert using ((float)lat, (float)lon) as a key // but depending on whether MapDB does tree path compression this might take more space WebMercatorTile tile = tileForWay(wayId, way); if (tile == null) { LOG.debug("Attempted insert way {} into the spatial index, but it is not currently in the database.", wayId); } else { this.index.add(new Tuple3(tile.xtile, tile.ytile, wayId)); } }
public Fun.Tuple3<Long, Long, Long> getSegmentId() { return new Fun.Tuple3<>(this.wayId, this.startNodeId, this.endNodeId); }
public void unIndexWay(long wayId) { Way way = ways.get(wayId); if (way == null) { LOG.debug("Attempted to remove way {} from the spatial index, but it is not currently in the database.", wayId); } else { WebMercatorTile tile = tileForWay(wayId, way); if (tile != null) { this.index.remove(new Tuple3(tile.xtile, tile.ytile, wayId)); } } }