/** * @return {@link File} object of the parent directory */ public File parent() { return new File(this.javaFile.getParent()); }
private static List<File> fetchAtlasFilesInDirectory(final Path directory) { return new File(directory.toFile()).listFilesRecursively().stream() .filter(AtlasResourceLoader.IS_ATLAS).collect(Collectors.toList()); }
private static List<File> fetchAtlasFilesInDirectory(final Path directory) { return new File(directory.toFile()).listFilesRecursively().stream().filter(IS_ATLAS) .collect(Collectors.toList()); } }
/** * Load a multi atlas if directory, otherwise load single atlas. * * @param path * An atlas shard directory or a single atlas. * @return An atlas object. */ private Atlas load(final Path path) { return ATLAS_RESOURCE_LOADER.load(new File(path.toFile())); }
public File child(final String name) { if (!this.javaFile.isDirectory()) { throw new CoreException("Cannot create the child of a file. It has to be a folder."); } this.javaFile.mkdirs(); return new File(getAbsolutePath() + "/" + name); }
private static CountryBoundaryMap initializeCountryBoundaryMap(final String value) { final Time start = Time.now(); logger.info("Loading boundaries"); final CountryBoundaryMap result = CountryBoundaryMap.fromPlainText(new File(value)); logger.info("Loaded boundaries in {}", start.elapsedSince()); return result; }
private Optional<Resource> fetchLocalFileResource(final URI resourceURI) { final String filePath = resourceURI.getPath(); return Optional.of(new File(filePath)); }
@Test public void testShardsInBounds() { // shards that should overlap a polygon in Copehagen Assert.assertTrue(PREDICATE.test(new File("/some/path/XYZ_11-1095-641.atlas.gz"))); Assert.assertTrue(PREDICATE.test(new File("/some/path/XYZ_11-1094-641.atlas.gz"))); Assert.assertTrue(PREDICATE.test(new File("/some/path/XYZ_11-1095-640.atlas.gz"))); Assert.assertTrue(PREDICATE.test(new File("/some/path/XYZ_11-1094-640.atlas.gz"))); Assert.assertTrue(PREDICATE.test(new File("/some/path/XYZ_10-548-320.atlas.gz"))); }
@Test public void testFilenameVariations() { // variations on valid filename final Predicate<Resource> myPredicate = new ShardFileOverlapsPolygon(SHARDING_TREE, POLYGON, "^.+_(\\d{1,2}-\\d+-\\d+)(\\.atlas)?(\\.gz)?$"); Assert.assertTrue(myPredicate.test(new File("/some/path/XYZ_11-1095-641.atlas.gz"))); Assert.assertTrue(myPredicate.test(new File("XYZ_11-1095-641.atlas.gz"))); Assert.assertTrue(myPredicate.test(new File("/some/path/XYZ_11-1095-641.atlas"))); Assert.assertTrue(myPredicate.test(new File("/some/path/XYZ_11-1095-641.gz"))); Assert.assertTrue(myPredicate.test(new File("/some/path/XYZ_11-1095-641"))); }
@Test public void testBadRegex() { // variations on valid filename final Predicate<Resource> myPredicate = new ShardFileOverlapsPolygon(SHARDING_TREE, POLYGON, "^.+_\\d{1,2}-\\d+-\\d+(\\.atlas)?(\\.gz)?$"); Assert.assertFalse(myPredicate.test(new File("/some/path/XYZ_11-1095-641.atlas.gz"))); Assert.assertFalse(myPredicate.test(new File("/some/path/XYZ_11-1095-641.atlas"))); Assert.assertFalse(myPredicate.test(new File("/some/path/XYZ_11-1095-641.gz"))); Assert.assertFalse(myPredicate.test(new File("/some/path/XYZ_11-1095-641"))); }
@BeforeClass public static void createBinaryAtlases() { final List<String> shardList = Arrays.asList(TXT_PATH + "/DNK_1.txt", TXT_PATH + "/DNK_2.txt", TXT_PATH + "/DNK_3.txt"); shardList.forEach(shard -> new TextAtlasBuilder().read(new File(shard)) .save(new File(SHARD_PATH.getPath() + shard.replace("txt", "atlas")))); }
@BeforeClass public static void createBinaryAtlases() { final List<String> shardList = Arrays.asList(TXT_PATH + "/DNK_1.txt", TXT_PATH + "/DNK_2.txt", TXT_PATH + "/DNK_3.txt"); shardList.forEach(shard -> new TextAtlasBuilder().read(new File(shard)) .save(new File(SHARD_PATH.getPath() + shard.replace("txt", "atlas")))); }
@Test public void missingDirectory() { Assert.assertNull(new AtlasResourceLoader().load(new File( Paths.get(System.getProperty("user.home"), "FileThatDoesntExist").toString()))); }
@Test public void shouldBeEmpty() { Assert.assertTrue(new File("/tmp/not/a/file").listFilesRecursively().isEmpty()); } }
@Override protected int onRun(final CommandMap command) { final CounterWithStatistic statistics = new CounterWithStatistic(logger); final Atlas multi = (Atlas) command.get(FOLDER); final File output = new File((String) command.get(OUTPUT)); statistics.summary(); final PackedAtlas packed = PackedAtlas.cloneFrom(multi); packed.save(output); return 0; }
@Test public void testRawAtlasCreation() { final String path = RawAtlasGeneratorTest.class.getResource("9-433-268.osm.pbf").getPath(); final RawAtlasGenerator rawAtlasGenerator = new RawAtlasGenerator(new File(path)); final Atlas atlas = rawAtlasGenerator.build(); // Verify Atlas Entities assertBasicRawAtlasPrinciples(atlas); Assert.assertEquals(52188, atlas.numberOfPoints()); Assert.assertEquals(6080, atlas.numberOfLines()); Assert.assertEquals(3, atlas.numberOfRelations()); }