From 819040377949f4ff590696d7401dca1dc1dbf4ee Mon Sep 17 00:00:00 2001 From: Dan Katzel Date: Sat, 11 Jul 2015 15:58:47 -0400 Subject: [PATCH] added support for country specific zip files that had extra readme.txt files in it. -minor improvement to not parse each Geoname object twice --- src/main/java/geocode/ReverseGeoCode.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/geocode/ReverseGeoCode.java b/src/main/java/geocode/ReverseGeoCode.java index 21d8a51..8fe1fab 100644 --- a/src/main/java/geocode/ReverseGeoCode.java +++ b/src/main/java/geocode/ReverseGeoCode.java @@ -30,6 +30,7 @@ of this software and associated documentation files (the "Software"), to deal import java.io.*; import java.util.ArrayList; +import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; /** @@ -53,7 +54,14 @@ public class ReverseGeoCode { * @throws NullPointerException if zippedPlacenames is {@code null}. */ public ReverseGeoCode( ZipInputStream zippedPlacednames, boolean majorOnly ) throws IOException { - zippedPlacednames.getNextEntry(); + //depending on which zip file is given, + //country specific zip files have read me files + //that we should ignore + ZipEntry entry; + do{ + entry = zippedPlacednames.getNextEntry(); + }while(entry.getName().equals("readme.txt")); + createKdTree(zippedPlacednames, majorOnly); } @@ -79,7 +87,7 @@ private void createKdTree(InputStream placenames, boolean majorOnly) while ((str = in.readLine()) != null) { GeoName newPlace = new GeoName(str); if ( !majorOnly || newPlace.majorPlace ) { - arPlaceNames.add(new GeoName(str)); + arPlaceNames.add(newPlace); } } } catch (IOException ex) {