Skip to content

Commit

Permalink
added support for country specific zip files that had extra readme.txt
Browse files Browse the repository at this point in the history
files in it.
-minor improvement to not parse each Geoname object twice
  • Loading branch information
dkatzel-home committed Jul 11, 2015
1 parent 33bfc82 commit 8190403
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/geocode/ReverseGeoCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);

}
Expand All @@ -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) {
Expand Down

0 comments on commit 8190403

Please sign in to comment.