Skip to content

Commit

Permalink
Merge pull request #614 from nicolas-f/importOsmFileExtension
Browse files Browse the repository at this point in the history
About #613 handle wrong file extension with a more explicit error
  • Loading branch information
pierromond authored Sep 25, 2023
2 parents 7fbcbef + e41eb98 commit 87594f5
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 87594f5

Please sign in to comment.