Skip to content

Commit

Permalink
About Universite-Gustave-Eiffel#613 handle wrong file extension with …
Browse files Browse the repository at this point in the history
…a more explicit error
  • Loading branch information
nicolas-f committed Sep 19, 2023
1 parent 7fbcbef commit e41eb98
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,15 @@ def exec(Connection connection, input) {

// Read the OSM file, depending on its extension
def reader
if (pathFile.endsWith(".pbf")) {
if (pathFile.toLowerCase(Locale.getDefault()).endsWith(".pbf")) {
InputStream inputStream = new FileInputStream(pathFile);
reader = new OsmosisReader(inputStream);
} else if (pathFile.endsWith(".osm")) {
} else if (pathFile.toLowerCase(Locale.getDefault()).endsWith(".osm")) {
reader = new XmlReader(new File(pathFile), true, CompressionMethod.None);
} else if (pathFile.endsWith(".osm.gz")) {
} else if (pathFile.toLowerCase(Locale.getDefault()).endsWith(".osm.gz")) {
reader = new XmlReader(new File(pathFile), true, CompressionMethod.GZip);
} else {
throw new IllegalArgumentException("File extension not known.Should be pbf, osm or osm.gz but got " + pathFile)
}

OsmHandler handler = new OsmHandler(logger, ignoreBuilding, ignoreRoads, ignoreGround, removeTunnels)
Expand Down

0 comments on commit e41eb98

Please sign in to comment.