@Test public void testMissingCoordinatesErrors() throws Exception { final String stackName = "test-stack"; final Double z = 9.9; final CoordinateClient client = new CoordinateClient(stackName, z, null, 1); final List<List<TileCoordinates>> worldListOfLists = new ArrayList<>(); final String nullTileIdForOutOfBoundsCoordinate = null; worldListOfLists.add( Collections.singletonList(TileCoordinates.buildWorldInstance(nullTileIdForOutOfBoundsCoordinate, new double[]{0, 0}))); worldListOfLists.add( Collections.singletonList(TileCoordinates.buildWorldInstance(nullTileIdForOutOfBoundsCoordinate, new double[]{1, 1}))); final List<TransformSpec> emptyTransformSpecList = new ArrayList<>(); final List<TileSpec> emptyTileSpecList = new ArrayList<>(); final ResolvedTileSpecCollection tiles = new ResolvedTileSpecCollection(emptyTransformSpecList, emptyTileSpecList); final List<List<TileCoordinates>> localListOfLists = client.worldToLocal(worldListOfLists, tiles); Assert.assertEquals("invalid number of local lists returned", worldListOfLists.size(), localListOfLists.size()); List<TileCoordinates> localList; TileCoordinates localCoordinates; String errorMessage; for (int i = 0; i < 2; i++) { localList = localListOfLists.get(i); Assert.assertEquals("invalid number of coordinates in local list " + i, 1, localList.size()); localCoordinates = localList.get(0); Assert.assertNull("tileId for coordinates in local list " + i + " should be null", localCoordinates.getTileId()); Assert.assertNull("local coordinates in local list " + i + " should be null", localCoordinates.getLocal()); errorMessage = localCoordinates.getError(); Assert.assertNotNull("local coordinates in local list " + i + " should have error", errorMessage); Assert.assertTrue("local coordinates in local list " + i + " has invalid error message '" + errorMessage + "'", errorMessage.matches("no tile.*" + i + ".0,.*")); } }
public List<List<TileCoordinates>> worldToLocal(final List<List<TileCoordinates>> worldListOfLists, final ResolvedTileSpecCollection tiles) throws IOException, InterruptedException { final List<List<TileCoordinates>> localListOfLists; if (numberOfThreads > 1) { localListOfLists = new ArrayList<>(worldListOfLists.size()); final List<Integer> batchIndexes = getBatchIndexes(numberOfThreads, worldListOfLists.size()); final List<WorldToLocalMapper> mapperList = new ArrayList<>(numberOfThreads); LOG.info("worldToLocal: mapping {} coordinate lists using {} threads", worldListOfLists.size(), batchIndexes.size() - 1); for (int i = 1; i < batchIndexes.size(); i++) { final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, batchIndexes.get(i-1), batchIndexes.get(i)); mapperList.add(mapper); mapper.start(); } for (final WorldToLocalMapper mapper : mapperList) { LOG.info("worldToLocal: waiting for {} to finish ...", mapper); mapper.join(); localListOfLists.addAll(mapper.getLocalListOfLists()); } } else { LOG.info("worldToLocal: entry, mapping {} coordinate lists on main thread", worldListOfLists.size()); final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, 0, worldListOfLists.size()); mapper.run(); localListOfLists = mapper.getLocalListOfLists(); } LOG.info("worldToLocal: exit, returning {} lists of local coordinates", localListOfLists.size()); return localListOfLists; }
CoordinateClient { public List<List<TileCoordinates>> worldToLocal(final List<List<TileCoordinates>> worldListOfLists, final ResolvedTileSpecCollection tiles) throws IOException, InterruptedException { final List<List<TileCoordinates>> localListOfLists; if (numberOfThreads > 1) { localListOfLists = new ArrayList<>(worldListOfLists.size()); final List<Integer> batchIndexes = getBatchIndexes(numberOfThreads, worldListOfLists.size()); final List<WorldToLocalMapper> mapperList = new ArrayList<>(numberOfThreads); LOG.info("worldToLocal: mapping {} coordinate lists using {} threads", worldListOfLists.size(), batchIndexes.size() - 1); for (int i = 1; i < batchIndexes.size(); i++) { final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, batchIndexes.get(i-1), batchIndexes.get(i)); mapperList.add(mapper); mapper.start(); } for (final WorldToLocalMapper mapper : mapperList) { LOG.info("worldToLocal: waiting for {} to finish ...", mapper); mapper.join(); localListOfLists.addAll(mapper.getLocalListOfLists()); } } else { LOG.info("worldToLocal: entry, mapping {} coordinate lists on main thread", worldListOfLists.size()); final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, 0, worldListOfLists.size()); mapper.run(); localListOfLists = mapper.getLocalListOfLists(); } LOG.info("worldToLocal: exit, returning {} lists of local coordinates", localListOfLists.size()); return localListOfLists; } }
CoordinateClient { public List<List<TileCoordinates>> worldToLocal(final List<List<TileCoordinates>> worldListOfLists, final ResolvedTileSpecCollection tiles) throws IOException, InterruptedException { final List<List<TileCoordinates>> localListOfLists; if (numberOfThreads > 1) { localListOfLists = new ArrayList<>(worldListOfLists.size()); final List<Integer> batchIndexes = getBatchIndexes(numberOfThreads, worldListOfLists.size()); final List<WorldToLocalMapper> mapperList = new ArrayList<>(numberOfThreads); LOG.info("worldToLocal: mapping {} coordinate lists using {} threads", worldListOfLists.size(), batchIndexes.size() - 1); for (int i = 1; i < batchIndexes.size(); i++) { final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, batchIndexes.get(i-1), batchIndexes.get(i)); mapperList.add(mapper); mapper.start(); } for (final WorldToLocalMapper mapper : mapperList) { LOG.info("worldToLocal: waiting for {} to finish ...", mapper); mapper.join(); localListOfLists.addAll(mapper.getLocalListOfLists()); } } else { LOG.info("worldToLocal: entry, mapping {} coordinate lists on main thread", worldListOfLists.size()); final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, 0, worldListOfLists.size()); mapper.run(); localListOfLists = mapper.getLocalListOfLists(); } LOG.info("worldToLocal: exit, returning {} lists of local coordinates", localListOfLists.size()); return localListOfLists; } CoordinateClient(final String stack,
                            final Double z,
                            final RenderDataClient renderDataClient,
                            final int numberOfThreads); }
CoordinateClient { public List<List<TileCoordinates>> worldToLocal(final List<List<TileCoordinates>> worldListOfLists, final ResolvedTileSpecCollection tiles) throws IOException, InterruptedException { final List<List<TileCoordinates>> localListOfLists; if (numberOfThreads > 1) { localListOfLists = new ArrayList<>(worldListOfLists.size()); final List<Integer> batchIndexes = getBatchIndexes(numberOfThreads, worldListOfLists.size()); final List<WorldToLocalMapper> mapperList = new ArrayList<>(numberOfThreads); LOG.info("worldToLocal: mapping {} coordinate lists using {} threads", worldListOfLists.size(), batchIndexes.size() - 1); for (int i = 1; i < batchIndexes.size(); i++) { final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, batchIndexes.get(i-1), batchIndexes.get(i)); mapperList.add(mapper); mapper.start(); } for (final WorldToLocalMapper mapper : mapperList) { LOG.info("worldToLocal: waiting for {} to finish ...", mapper); mapper.join(); localListOfLists.addAll(mapper.getLocalListOfLists()); } } else { LOG.info("worldToLocal: entry, mapping {} coordinate lists on main thread", worldListOfLists.size()); final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, 0, worldListOfLists.size()); mapper.run(); localListOfLists = mapper.getLocalListOfLists(); } LOG.info("worldToLocal: exit, returning {} lists of local coordinates", localListOfLists.size()); return localListOfLists; } CoordinateClient(final String stack,
                            final Double z,
                            final RenderDataClient renderDataClient,
                            final int numberOfThreads); static void main(final String[] args); @Override String toString(); StackVersion getStackVersion(); List<List<TileCoordinates>> getWorldCoordinatesWithTileIds(final List<TileCoordinates> worldCoordinatesList); List<List<TileCoordinates>> worldToLocalInBatches(final List<TileCoordinates> loadedWorldCoordinates); List<List<TileCoordinates>> worldToLocal(final List<List<TileCoordinates>> worldListOfLists,
                                                    final ResolvedTileSpecCollection tiles); List<TileCoordinates> localToWorldInBatches(final List<List<TileCoordinates>> loadedLocalCoordinates); List<TileCoordinates> localToWorld(final List<List<TileCoordinates>> localListOfLists,
                                              final ResolvedTileSpecCollection tiles); static List<TileCoordinates> loadJsonArrayOfCoordinates(final String path); static List<List<TileCoordinates>> loadJsonArrayOfArraysOfCoordinates(final String path); static List<Integer> getBatchIndexes(final int numberOfThreads,
                                                final int size); }
CoordinateClient { public List<List<TileCoordinates>> worldToLocal(final List<List<TileCoordinates>> worldListOfLists, final ResolvedTileSpecCollection tiles) throws IOException, InterruptedException { final List<List<TileCoordinates>> localListOfLists; if (numberOfThreads > 1) { localListOfLists = new ArrayList<>(worldListOfLists.size()); final List<Integer> batchIndexes = getBatchIndexes(numberOfThreads, worldListOfLists.size()); final List<WorldToLocalMapper> mapperList = new ArrayList<>(numberOfThreads); LOG.info("worldToLocal: mapping {} coordinate lists using {} threads", worldListOfLists.size(), batchIndexes.size() - 1); for (int i = 1; i < batchIndexes.size(); i++) { final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, batchIndexes.get(i-1), batchIndexes.get(i)); mapperList.add(mapper); mapper.start(); } for (final WorldToLocalMapper mapper : mapperList) { LOG.info("worldToLocal: waiting for {} to finish ...", mapper); mapper.join(); localListOfLists.addAll(mapper.getLocalListOfLists()); } } else { LOG.info("worldToLocal: entry, mapping {} coordinate lists on main thread", worldListOfLists.size()); final WorldToLocalMapper mapper = new WorldToLocalMapper(stack, z, tiles, worldListOfLists, 0, worldListOfLists.size()); mapper.run(); localListOfLists = mapper.getLocalListOfLists(); } LOG.info("worldToLocal: exit, returning {} lists of local coordinates", localListOfLists.size()); return localListOfLists; } CoordinateClient(final String stack,
                            final Double z,
                            final RenderDataClient renderDataClient,
                            final int numberOfThreads); static void main(final String[] args); @Override String toString(); StackVersion getStackVersion(); List<List<TileCoordinates>> getWorldCoordinatesWithTileIds(final List<TileCoordinates> worldCoordinatesList); List<List<TileCoordinates>> worldToLocalInBatches(final List<TileCoordinates> loadedWorldCoordinates); List<List<TileCoordinates>> worldToLocal(final List<List<TileCoordinates>> worldListOfLists,
                                                    final ResolvedTileSpecCollection tiles); List<TileCoordinates> localToWorldInBatches(final List<List<TileCoordinates>> loadedLocalCoordinates); List<TileCoordinates> localToWorld(final List<List<TileCoordinates>> localListOfLists,
                                              final ResolvedTileSpecCollection tiles); static List<TileCoordinates> loadJsonArrayOfCoordinates(final String path); static List<List<TileCoordinates>> loadJsonArrayOfArraysOfCoordinates(final String path); static List<Integer> getBatchIndexes(final int numberOfThreads,
                                                final int size);  }