X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2FGetWikipediaFunction.java;fp=tim%2Fprune%2Ffunction%2FGetWikipediaFunction.java;h=aa326c2a00a0ea3f116575f892da6adb433519e5;hp=804ba714bbf1db0acc86fa36e1e65514c4498b27;hb=1a735a99408fd3b0c5ac4fe7b2fdbdbb23d38f40;hpb=92dad5df664287acb51728e9ea599f150765d34a diff --git a/tim/prune/function/GetWikipediaFunction.java b/tim/prune/function/GetWikipediaFunction.java index 804ba71..aa326c2 100644 --- a/tim/prune/function/GetWikipediaFunction.java +++ b/tim/prune/function/GetWikipediaFunction.java @@ -191,35 +191,33 @@ public class GetWikipediaFunction extends GenericDownloaderFunction { InputStream in = GetWikipediaFunction.class.getResourceAsStream("/tim/prune/function/search/wikimedia_galleries.txt"); reader = new BufferedReader(new InputStreamReader(in)); - if (reader != null) + + ArrayList trackList = new ArrayList(); + DataPoint herePoint = new DataPoint(new Latitude(inLat, Latitude.FORMAT_DEG), new Longitude(inLon, Longitude.FORMAT_DEG), null); + // Loop through the file line by line, looking for nearby points + String line = null; + while ((line = reader.readLine()) != null) { - ArrayList trackList = new ArrayList(); - DataPoint herePoint = new DataPoint(new Latitude(inLat, Latitude.FORMAT_DEG), new Longitude(inLon, Longitude.FORMAT_DEG), null); - // Loop through the file line by line, looking for nearby points - String line = null; - while ((line = reader.readLine()) != null) + String[] lineComps = line.split("\t"); + if (lineComps.length == 4) { - String[] lineComps = line.split("\t"); - if (lineComps.length == 4) + DataPoint p = new DataPoint(new Latitude(lineComps[2]), new Longitude(lineComps[3]), null); + double distFromHere = Distance.convertRadiansToDistance( + DataPoint.calculateRadiansBetween(p, herePoint), UnitSetLibrary.UNITS_KILOMETRES); + if (distFromHere < MAX_DISTANCE) { - DataPoint p = new DataPoint(new Latitude(lineComps[2]), new Longitude(lineComps[3]), null); - double distFromHere = Distance.convertRadiansToDistance( - DataPoint.calculateRadiansBetween(p, herePoint), UnitSetLibrary.UNITS_KILOMETRES); - if (distFromHere < MAX_DISTANCE) - { - SearchResult gallery = new SearchResult(); - gallery.setTrackName(I18nManager.getText("dialog.wikipedia.gallery") + ": " + lineComps[0]); - gallery.setDescription(lineComps[1]); - gallery.setLatitude(lineComps[2]); - gallery.setLongitude(lineComps[3]); - gallery.setWebUrl("https://commons.wikimedia.org/wiki/" + lineComps[0]); - gallery.setLength(distFromHere * 1000.0); // convert from km to m - trackList.add(gallery); - } + SearchResult gallery = new SearchResult(); + gallery.setTrackName(I18nManager.getText("dialog.wikipedia.gallery") + ": " + lineComps[0]); + gallery.setDescription(lineComps[1]); + gallery.setLatitude(lineComps[2]); + gallery.setLongitude(lineComps[3]); + gallery.setWebUrl("https://commons.wikimedia.org/wiki/" + lineComps[0]); + gallery.setLength(distFromHere * 1000.0); // convert from km to m + trackList.add(gallery); } } - _trackListModel.addTracks(trackList, true); } + _trackListModel.addTracks(trackList, true); } catch (java.io.IOException e) { System.err.println("Exception trying to read wikimedia file : " + e.getMessage());