@Test public void testCrossDeriveWithMissingLayers() throws Exception { final int zNeighborDistance = 2; final int expectedNumberOfPairs = 25; final String toJson = baseFileName + ".json"; final MockTilePairClient client = new MockTilePairClient(getTestParameters(zNeighborDistance, expectedNumberOfPairs, toJson), 1.0, 3.0, 5.0, 6.0, 7.0); client.deriveAndSaveSortedNeighborPairs(); final List<Path> pairFilePaths = new ArrayList<>(); Files.list(Paths.get(".")).forEach(path -> { if (path.getFileName().toString().startsWith(baseFileName)) { pairFilePaths.add(path); } }); Assert.assertEquals("invalid number of pairs files created", 1, pairFilePaths.size()); final File resultFile = pairFilePaths.get(0).toFile(); final FileReader resultReader = new FileReader(resultFile); final RenderableCanvasIdPairs renderableCanvasIdPairs = RenderableCanvasIdPairs.fromJson(resultReader); Assert.assertEquals("invalid number of pairs written", expectedNumberOfPairs, renderableCanvasIdPairs.size()); }
void deriveAndSaveSortedNeighborPairs() throws IllegalArgumentException, IOException { LOG.info("deriveAndSaveSortedNeighborPairs: entry"); final String renderParametersUrlTemplate = getRenderParametersUrlTemplate(); final List<Double> zValues = getZValues(); if (zValues.size() == 0) { throw new IllegalArgumentException( "stack " + parameters.stack + " does not contain any layers with the specified z values"); } Collections.sort(zValues); final double minZ = zValues.get(0); final double maxZ = zValues.get(zValues.size() - 1); ExistingMatchHelper existingMatchHelper = null; if (parameters.excludePairsInMatchCollection != null) { final String collectionName = parameters.excludePairsInMatchCollection; final RenderDataClient matchDataClient = new RenderDataClient(parameters.renderWeb.baseDataUrl, parameters.getMatchOwner(parameters.existingMatchOwner), collectionName); final List<MatchCollectionMetaData> matchCollections = matchDataClient.getOwnerMatchCollections(); final boolean foundCollection = matchCollections.stream() .anyMatch(md -> md.getCollectionId().getName().equals(collectionName)); if (foundCollection) { existingMatchHelper = new ExistingMatchHelper(parameters, renderDataClient, minZ, maxZ, matchDataClient); } } final Map<Double, TileBoundsRTree> zToTreeMap = new LinkedHashMap<>(zValues.size()); double z; for (int zIndex = 0; (zIndex < zValues.size()) && (zIndex < parameters.zNeighborDistance); zIndex++) { z = zValues.get(zIndex); zToTreeMap.put(z, buildRTree(z)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(z); } } if ((parameters.zNeighborDistance == 0) && (existingMatchHelper != null)) { existingMatchHelper.addExistingPairs(zValues.get(0)); } final Set<OrderedCanvasIdPair> neighborPairs = new TreeSet<>(); int totalSavedPairCount = 0; Double neighborZ; TileBoundsRTree currentZTree; List<TileBoundsRTree> neighborTreeList; Set<OrderedCanvasIdPair> currentNeighborPairs; for (int zIndex = 0; zIndex < zValues.size(); zIndex++) { z = zValues.get(zIndex); if (parameters.zNeighborDistance == 0) { zToTreeMap.put(z, buildRTree(z)); } neighborTreeList = new ArrayList<>(); final double idealMaxNeighborZ = Math.min(maxZ, z + parameters.zNeighborDistance); for (int neighborZIndex = zIndex + 1; neighborZIndex < zValues.size(); neighborZIndex++) { neighborZ = zValues.get(neighborZIndex); if (neighborZ > idealMaxNeighborZ) { break; } if (! zToTreeMap.containsKey(neighborZ)) { if (zIndex > 0) { final double completedZ = zValues.get(zIndex - 1); zToTreeMap.remove(completedZ); } zToTreeMap.put(neighborZ, buildRTree(neighborZ)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(neighborZ); } } neighborTreeList.add(zToTreeMap.get(neighborZ)); } currentZTree = zToTreeMap.get(z); final List<TileBounds> sourceTileBoundsList; if (sourceTileIds == null) { sourceTileBoundsList = currentZTree.getTileBoundsList(); } else { sourceTileBoundsList = currentZTree.getTileBoundsList().stream() .filter(tb -> sourceTileIds.contains(tb.getTileId())) .collect(Collectors.toList()); } currentNeighborPairs = currentZTree.getCircleNeighbors(sourceTileBoundsList, neighborTreeList, parameters.xyNeighborFactor, parameters.explicitRadius, parameters.excludeCornerNeighbors, parameters.excludeSameLayerNeighbors, parameters.excludeSameSectionNeighbors); if (existingMatchHelper != null) { existingMatchHelper.removeExistingPairs(z, currentNeighborPairs); final int nextIndex = zIndex + 1; if ((parameters.zNeighborDistance == 0) && (nextIndex < zValues.size())) { existingMatchHelper.addExistingPairs(zValues.get(nextIndex)); } } neighborPairs.addAll(currentNeighborPairs); if (neighborPairs.size() > parameters.maxPairsPerFile) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); int fromIndex = 0; for (; ; fromIndex += parameters.maxPairsPerFile) { final int toIndex = fromIndex + parameters.maxPairsPerFile; if (toIndex <= neighborPairs.size()) { savePairs(neighborPairsList.subList(fromIndex, toIndex), renderParametersUrlTemplate, getOutputFileName()); numberOfOutputFiles++; totalSavedPairCount += parameters.maxPairsPerFile; } else { break; } } neighborPairs.clear(); neighborPairs.addAll(neighborPairsList.subList(fromIndex, neighborPairsList.size())); } } if (neighborPairs.size() > 0) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); final String outputFileName = numberOfOutputFiles == 0 ? parameters.toJson : getOutputFileName(); savePairs(neighborPairsList, renderParametersUrlTemplate, outputFileName); totalSavedPairCount += neighborPairs.size(); } LOG.info("deriveAndSaveSortedNeighborPairs: exit, saved {} total pairs", totalSavedPairCount); }
TilePairClient { void deriveAndSaveSortedNeighborPairs() throws IllegalArgumentException, IOException { LOG.info("deriveAndSaveSortedNeighborPairs: entry"); final String renderParametersUrlTemplate = getRenderParametersUrlTemplate(); final List<Double> zValues = getZValues(); if (zValues.size() == 0) { throw new IllegalArgumentException( "stack " + parameters.stack + " does not contain any layers with the specified z values"); } Collections.sort(zValues); final double minZ = zValues.get(0); final double maxZ = zValues.get(zValues.size() - 1); ExistingMatchHelper existingMatchHelper = null; if (parameters.excludePairsInMatchCollection != null) { final String collectionName = parameters.excludePairsInMatchCollection; final RenderDataClient matchDataClient = new RenderDataClient(parameters.renderWeb.baseDataUrl, parameters.getMatchOwner(parameters.existingMatchOwner), collectionName); final List<MatchCollectionMetaData> matchCollections = matchDataClient.getOwnerMatchCollections(); final boolean foundCollection = matchCollections.stream() .anyMatch(md -> md.getCollectionId().getName().equals(collectionName)); if (foundCollection) { existingMatchHelper = new ExistingMatchHelper(parameters, renderDataClient, minZ, maxZ, matchDataClient); } } final Map<Double, TileBoundsRTree> zToTreeMap = new LinkedHashMap<>(zValues.size()); double z; for (int zIndex = 0; (zIndex < zValues.size()) && (zIndex < parameters.zNeighborDistance); zIndex++) { z = zValues.get(zIndex); zToTreeMap.put(z, buildRTree(z)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(z); } } if ((parameters.zNeighborDistance == 0) && (existingMatchHelper != null)) { existingMatchHelper.addExistingPairs(zValues.get(0)); } final Set<OrderedCanvasIdPair> neighborPairs = new TreeSet<>(); int totalSavedPairCount = 0; Double neighborZ; TileBoundsRTree currentZTree; List<TileBoundsRTree> neighborTreeList; Set<OrderedCanvasIdPair> currentNeighborPairs; for (int zIndex = 0; zIndex < zValues.size(); zIndex++) { z = zValues.get(zIndex); if (parameters.zNeighborDistance == 0) { zToTreeMap.put(z, buildRTree(z)); } neighborTreeList = new ArrayList<>(); final double idealMaxNeighborZ = Math.min(maxZ, z + parameters.zNeighborDistance); for (int neighborZIndex = zIndex + 1; neighborZIndex < zValues.size(); neighborZIndex++) { neighborZ = zValues.get(neighborZIndex); if (neighborZ > idealMaxNeighborZ) { break; } if (! zToTreeMap.containsKey(neighborZ)) { if (zIndex > 0) { final double completedZ = zValues.get(zIndex - 1); zToTreeMap.remove(completedZ); } zToTreeMap.put(neighborZ, buildRTree(neighborZ)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(neighborZ); } } neighborTreeList.add(zToTreeMap.get(neighborZ)); } currentZTree = zToTreeMap.get(z); final List<TileBounds> sourceTileBoundsList; if (sourceTileIds == null) { sourceTileBoundsList = currentZTree.getTileBoundsList(); } else { sourceTileBoundsList = currentZTree.getTileBoundsList().stream() .filter(tb -> sourceTileIds.contains(tb.getTileId())) .collect(Collectors.toList()); } currentNeighborPairs = currentZTree.getCircleNeighbors(sourceTileBoundsList, neighborTreeList, parameters.xyNeighborFactor, parameters.explicitRadius, parameters.excludeCornerNeighbors, parameters.excludeSameLayerNeighbors, parameters.excludeSameSectionNeighbors); if (existingMatchHelper != null) { existingMatchHelper.removeExistingPairs(z, currentNeighborPairs); final int nextIndex = zIndex + 1; if ((parameters.zNeighborDistance == 0) && (nextIndex < zValues.size())) { existingMatchHelper.addExistingPairs(zValues.get(nextIndex)); } } neighborPairs.addAll(currentNeighborPairs); if (neighborPairs.size() > parameters.maxPairsPerFile) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); int fromIndex = 0; for (; ; fromIndex += parameters.maxPairsPerFile) { final int toIndex = fromIndex + parameters.maxPairsPerFile; if (toIndex <= neighborPairs.size()) { savePairs(neighborPairsList.subList(fromIndex, toIndex), renderParametersUrlTemplate, getOutputFileName()); numberOfOutputFiles++; totalSavedPairCount += parameters.maxPairsPerFile; } else { break; } } neighborPairs.clear(); neighborPairs.addAll(neighborPairsList.subList(fromIndex, neighborPairsList.size())); } } if (neighborPairs.size() > 0) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); final String outputFileName = numberOfOutputFiles == 0 ? parameters.toJson : getOutputFileName(); savePairs(neighborPairsList, renderParametersUrlTemplate, outputFileName); totalSavedPairCount += neighborPairs.size(); } LOG.info("deriveAndSaveSortedNeighborPairs: exit, saved {} total pairs", totalSavedPairCount); } }
TilePairClient { void deriveAndSaveSortedNeighborPairs() throws IllegalArgumentException, IOException { LOG.info("deriveAndSaveSortedNeighborPairs: entry"); final String renderParametersUrlTemplate = getRenderParametersUrlTemplate(); final List<Double> zValues = getZValues(); if (zValues.size() == 0) { throw new IllegalArgumentException( "stack " + parameters.stack + " does not contain any layers with the specified z values"); } Collections.sort(zValues); final double minZ = zValues.get(0); final double maxZ = zValues.get(zValues.size() - 1); ExistingMatchHelper existingMatchHelper = null; if (parameters.excludePairsInMatchCollection != null) { final String collectionName = parameters.excludePairsInMatchCollection; final RenderDataClient matchDataClient = new RenderDataClient(parameters.renderWeb.baseDataUrl, parameters.getMatchOwner(parameters.existingMatchOwner), collectionName); final List<MatchCollectionMetaData> matchCollections = matchDataClient.getOwnerMatchCollections(); final boolean foundCollection = matchCollections.stream() .anyMatch(md -> md.getCollectionId().getName().equals(collectionName)); if (foundCollection) { existingMatchHelper = new ExistingMatchHelper(parameters, renderDataClient, minZ, maxZ, matchDataClient); } } final Map<Double, TileBoundsRTree> zToTreeMap = new LinkedHashMap<>(zValues.size()); double z; for (int zIndex = 0; (zIndex < zValues.size()) && (zIndex < parameters.zNeighborDistance); zIndex++) { z = zValues.get(zIndex); zToTreeMap.put(z, buildRTree(z)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(z); } } if ((parameters.zNeighborDistance == 0) && (existingMatchHelper != null)) { existingMatchHelper.addExistingPairs(zValues.get(0)); } final Set<OrderedCanvasIdPair> neighborPairs = new TreeSet<>(); int totalSavedPairCount = 0; Double neighborZ; TileBoundsRTree currentZTree; List<TileBoundsRTree> neighborTreeList; Set<OrderedCanvasIdPair> currentNeighborPairs; for (int zIndex = 0; zIndex < zValues.size(); zIndex++) { z = zValues.get(zIndex); if (parameters.zNeighborDistance == 0) { zToTreeMap.put(z, buildRTree(z)); } neighborTreeList = new ArrayList<>(); final double idealMaxNeighborZ = Math.min(maxZ, z + parameters.zNeighborDistance); for (int neighborZIndex = zIndex + 1; neighborZIndex < zValues.size(); neighborZIndex++) { neighborZ = zValues.get(neighborZIndex); if (neighborZ > idealMaxNeighborZ) { break; } if (! zToTreeMap.containsKey(neighborZ)) { if (zIndex > 0) { final double completedZ = zValues.get(zIndex - 1); zToTreeMap.remove(completedZ); } zToTreeMap.put(neighborZ, buildRTree(neighborZ)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(neighborZ); } } neighborTreeList.add(zToTreeMap.get(neighborZ)); } currentZTree = zToTreeMap.get(z); final List<TileBounds> sourceTileBoundsList; if (sourceTileIds == null) { sourceTileBoundsList = currentZTree.getTileBoundsList(); } else { sourceTileBoundsList = currentZTree.getTileBoundsList().stream() .filter(tb -> sourceTileIds.contains(tb.getTileId())) .collect(Collectors.toList()); } currentNeighborPairs = currentZTree.getCircleNeighbors(sourceTileBoundsList, neighborTreeList, parameters.xyNeighborFactor, parameters.explicitRadius, parameters.excludeCornerNeighbors, parameters.excludeSameLayerNeighbors, parameters.excludeSameSectionNeighbors); if (existingMatchHelper != null) { existingMatchHelper.removeExistingPairs(z, currentNeighborPairs); final int nextIndex = zIndex + 1; if ((parameters.zNeighborDistance == 0) && (nextIndex < zValues.size())) { existingMatchHelper.addExistingPairs(zValues.get(nextIndex)); } } neighborPairs.addAll(currentNeighborPairs); if (neighborPairs.size() > parameters.maxPairsPerFile) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); int fromIndex = 0; for (; ; fromIndex += parameters.maxPairsPerFile) { final int toIndex = fromIndex + parameters.maxPairsPerFile; if (toIndex <= neighborPairs.size()) { savePairs(neighborPairsList.subList(fromIndex, toIndex), renderParametersUrlTemplate, getOutputFileName()); numberOfOutputFiles++; totalSavedPairCount += parameters.maxPairsPerFile; } else { break; } } neighborPairs.clear(); neighborPairs.addAll(neighborPairsList.subList(fromIndex, neighborPairsList.size())); } } if (neighborPairs.size() > 0) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); final String outputFileName = numberOfOutputFiles == 0 ? parameters.toJson : getOutputFileName(); savePairs(neighborPairsList, renderParametersUrlTemplate, outputFileName); totalSavedPairCount += neighborPairs.size(); } LOG.info("deriveAndSaveSortedNeighborPairs: exit, saved {} total pairs", totalSavedPairCount); } TilePairClient(final Parameters parameters); }
TilePairClient { void deriveAndSaveSortedNeighborPairs() throws IllegalArgumentException, IOException { LOG.info("deriveAndSaveSortedNeighborPairs: entry"); final String renderParametersUrlTemplate = getRenderParametersUrlTemplate(); final List<Double> zValues = getZValues(); if (zValues.size() == 0) { throw new IllegalArgumentException( "stack " + parameters.stack + " does not contain any layers with the specified z values"); } Collections.sort(zValues); final double minZ = zValues.get(0); final double maxZ = zValues.get(zValues.size() - 1); ExistingMatchHelper existingMatchHelper = null; if (parameters.excludePairsInMatchCollection != null) { final String collectionName = parameters.excludePairsInMatchCollection; final RenderDataClient matchDataClient = new RenderDataClient(parameters.renderWeb.baseDataUrl, parameters.getMatchOwner(parameters.existingMatchOwner), collectionName); final List<MatchCollectionMetaData> matchCollections = matchDataClient.getOwnerMatchCollections(); final boolean foundCollection = matchCollections.stream() .anyMatch(md -> md.getCollectionId().getName().equals(collectionName)); if (foundCollection) { existingMatchHelper = new ExistingMatchHelper(parameters, renderDataClient, minZ, maxZ, matchDataClient); } } final Map<Double, TileBoundsRTree> zToTreeMap = new LinkedHashMap<>(zValues.size()); double z; for (int zIndex = 0; (zIndex < zValues.size()) && (zIndex < parameters.zNeighborDistance); zIndex++) { z = zValues.get(zIndex); zToTreeMap.put(z, buildRTree(z)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(z); } } if ((parameters.zNeighborDistance == 0) && (existingMatchHelper != null)) { existingMatchHelper.addExistingPairs(zValues.get(0)); } final Set<OrderedCanvasIdPair> neighborPairs = new TreeSet<>(); int totalSavedPairCount = 0; Double neighborZ; TileBoundsRTree currentZTree; List<TileBoundsRTree> neighborTreeList; Set<OrderedCanvasIdPair> currentNeighborPairs; for (int zIndex = 0; zIndex < zValues.size(); zIndex++) { z = zValues.get(zIndex); if (parameters.zNeighborDistance == 0) { zToTreeMap.put(z, buildRTree(z)); } neighborTreeList = new ArrayList<>(); final double idealMaxNeighborZ = Math.min(maxZ, z + parameters.zNeighborDistance); for (int neighborZIndex = zIndex + 1; neighborZIndex < zValues.size(); neighborZIndex++) { neighborZ = zValues.get(neighborZIndex); if (neighborZ > idealMaxNeighborZ) { break; } if (! zToTreeMap.containsKey(neighborZ)) { if (zIndex > 0) { final double completedZ = zValues.get(zIndex - 1); zToTreeMap.remove(completedZ); } zToTreeMap.put(neighborZ, buildRTree(neighborZ)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(neighborZ); } } neighborTreeList.add(zToTreeMap.get(neighborZ)); } currentZTree = zToTreeMap.get(z); final List<TileBounds> sourceTileBoundsList; if (sourceTileIds == null) { sourceTileBoundsList = currentZTree.getTileBoundsList(); } else { sourceTileBoundsList = currentZTree.getTileBoundsList().stream() .filter(tb -> sourceTileIds.contains(tb.getTileId())) .collect(Collectors.toList()); } currentNeighborPairs = currentZTree.getCircleNeighbors(sourceTileBoundsList, neighborTreeList, parameters.xyNeighborFactor, parameters.explicitRadius, parameters.excludeCornerNeighbors, parameters.excludeSameLayerNeighbors, parameters.excludeSameSectionNeighbors); if (existingMatchHelper != null) { existingMatchHelper.removeExistingPairs(z, currentNeighborPairs); final int nextIndex = zIndex + 1; if ((parameters.zNeighborDistance == 0) && (nextIndex < zValues.size())) { existingMatchHelper.addExistingPairs(zValues.get(nextIndex)); } } neighborPairs.addAll(currentNeighborPairs); if (neighborPairs.size() > parameters.maxPairsPerFile) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); int fromIndex = 0; for (; ; fromIndex += parameters.maxPairsPerFile) { final int toIndex = fromIndex + parameters.maxPairsPerFile; if (toIndex <= neighborPairs.size()) { savePairs(neighborPairsList.subList(fromIndex, toIndex), renderParametersUrlTemplate, getOutputFileName()); numberOfOutputFiles++; totalSavedPairCount += parameters.maxPairsPerFile; } else { break; } } neighborPairs.clear(); neighborPairs.addAll(neighborPairsList.subList(fromIndex, neighborPairsList.size())); } } if (neighborPairs.size() > 0) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); final String outputFileName = numberOfOutputFiles == 0 ? parameters.toJson : getOutputFileName(); savePairs(neighborPairsList, renderParametersUrlTemplate, outputFileName); totalSavedPairCount += neighborPairs.size(); } LOG.info("deriveAndSaveSortedNeighborPairs: exit, saved {} total pairs", totalSavedPairCount); } TilePairClient(final Parameters parameters); static void main(final String[] args); List<Double> getZValues(); TileBoundsRTree buildRTree(final double z); }
TilePairClient { void deriveAndSaveSortedNeighborPairs() throws IllegalArgumentException, IOException { LOG.info("deriveAndSaveSortedNeighborPairs: entry"); final String renderParametersUrlTemplate = getRenderParametersUrlTemplate(); final List<Double> zValues = getZValues(); if (zValues.size() == 0) { throw new IllegalArgumentException( "stack " + parameters.stack + " does not contain any layers with the specified z values"); } Collections.sort(zValues); final double minZ = zValues.get(0); final double maxZ = zValues.get(zValues.size() - 1); ExistingMatchHelper existingMatchHelper = null; if (parameters.excludePairsInMatchCollection != null) { final String collectionName = parameters.excludePairsInMatchCollection; final RenderDataClient matchDataClient = new RenderDataClient(parameters.renderWeb.baseDataUrl, parameters.getMatchOwner(parameters.existingMatchOwner), collectionName); final List<MatchCollectionMetaData> matchCollections = matchDataClient.getOwnerMatchCollections(); final boolean foundCollection = matchCollections.stream() .anyMatch(md -> md.getCollectionId().getName().equals(collectionName)); if (foundCollection) { existingMatchHelper = new ExistingMatchHelper(parameters, renderDataClient, minZ, maxZ, matchDataClient); } } final Map<Double, TileBoundsRTree> zToTreeMap = new LinkedHashMap<>(zValues.size()); double z; for (int zIndex = 0; (zIndex < zValues.size()) && (zIndex < parameters.zNeighborDistance); zIndex++) { z = zValues.get(zIndex); zToTreeMap.put(z, buildRTree(z)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(z); } } if ((parameters.zNeighborDistance == 0) && (existingMatchHelper != null)) { existingMatchHelper.addExistingPairs(zValues.get(0)); } final Set<OrderedCanvasIdPair> neighborPairs = new TreeSet<>(); int totalSavedPairCount = 0; Double neighborZ; TileBoundsRTree currentZTree; List<TileBoundsRTree> neighborTreeList; Set<OrderedCanvasIdPair> currentNeighborPairs; for (int zIndex = 0; zIndex < zValues.size(); zIndex++) { z = zValues.get(zIndex); if (parameters.zNeighborDistance == 0) { zToTreeMap.put(z, buildRTree(z)); } neighborTreeList = new ArrayList<>(); final double idealMaxNeighborZ = Math.min(maxZ, z + parameters.zNeighborDistance); for (int neighborZIndex = zIndex + 1; neighborZIndex < zValues.size(); neighborZIndex++) { neighborZ = zValues.get(neighborZIndex); if (neighborZ > idealMaxNeighborZ) { break; } if (! zToTreeMap.containsKey(neighborZ)) { if (zIndex > 0) { final double completedZ = zValues.get(zIndex - 1); zToTreeMap.remove(completedZ); } zToTreeMap.put(neighborZ, buildRTree(neighborZ)); if (existingMatchHelper != null) { existingMatchHelper.addExistingPairs(neighborZ); } } neighborTreeList.add(zToTreeMap.get(neighborZ)); } currentZTree = zToTreeMap.get(z); final List<TileBounds> sourceTileBoundsList; if (sourceTileIds == null) { sourceTileBoundsList = currentZTree.getTileBoundsList(); } else { sourceTileBoundsList = currentZTree.getTileBoundsList().stream() .filter(tb -> sourceTileIds.contains(tb.getTileId())) .collect(Collectors.toList()); } currentNeighborPairs = currentZTree.getCircleNeighbors(sourceTileBoundsList, neighborTreeList, parameters.xyNeighborFactor, parameters.explicitRadius, parameters.excludeCornerNeighbors, parameters.excludeSameLayerNeighbors, parameters.excludeSameSectionNeighbors); if (existingMatchHelper != null) { existingMatchHelper.removeExistingPairs(z, currentNeighborPairs); final int nextIndex = zIndex + 1; if ((parameters.zNeighborDistance == 0) && (nextIndex < zValues.size())) { existingMatchHelper.addExistingPairs(zValues.get(nextIndex)); } } neighborPairs.addAll(currentNeighborPairs); if (neighborPairs.size() > parameters.maxPairsPerFile) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); int fromIndex = 0; for (; ; fromIndex += parameters.maxPairsPerFile) { final int toIndex = fromIndex + parameters.maxPairsPerFile; if (toIndex <= neighborPairs.size()) { savePairs(neighborPairsList.subList(fromIndex, toIndex), renderParametersUrlTemplate, getOutputFileName()); numberOfOutputFiles++; totalSavedPairCount += parameters.maxPairsPerFile; } else { break; } } neighborPairs.clear(); neighborPairs.addAll(neighborPairsList.subList(fromIndex, neighborPairsList.size())); } } if (neighborPairs.size() > 0) { final List<OrderedCanvasIdPair> neighborPairsList = new ArrayList<>(neighborPairs); final String outputFileName = numberOfOutputFiles == 0 ? parameters.toJson : getOutputFileName(); savePairs(neighborPairsList, renderParametersUrlTemplate, outputFileName); totalSavedPairCount += neighborPairs.size(); } LOG.info("deriveAndSaveSortedNeighborPairs: exit, saved {} total pairs", totalSavedPairCount); } TilePairClient(final Parameters parameters); static void main(final String[] args); List<Double> getZValues(); TileBoundsRTree buildRTree(final double z);  }