[tor-commits] [onionoo/master] Don't include empty latitude and longitude.
karsten at torproject.org
karsten at torproject.org
Tue Feb 25 17:38:09 UTC 2014
commit 7b485a6c4a7da82469d06e81587f404d46a80122
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Tue Feb 25 16:58:53 2014 +0100
Don't include empty latitude and longitude.
Example details document where this produces invalid JSON (extract only):
"""
"or_addresses":["93.114.41.153:9401"],
"country":"ro",
"latitude":,
"longitude":,
"country_name":"Romania",
"as_number":"AS39743",
"as_name":"Voxility S.R.L.",
"""
Lines in GeoLite2-City-Blocks.csv and -Locations.csv:
"""
::ffff:93.114.41.0,121,,798549,,,,,1,0
"""
"""
798549,EU,Europe,RO,Romania,,,,,Europe/Bucharest
"""
---
src/org/torproject/onionoo/LookupService.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/org/torproject/onionoo/LookupService.java b/src/org/torproject/onionoo/LookupService.java
index 3cfe3f2..39f4e2e 100644
--- a/src/org/torproject/onionoo/LookupService.java
+++ b/src/org/torproject/onionoo/LookupService.java
@@ -151,10 +151,10 @@ public class LookupService {
parts[3];
long blockNumber = Long.parseLong(blockString);
addressNumberBlocks.put(addressNumber, blockNumber);
- String latitude = parts[6];
- String longitude = parts[7];
- addressNumberLatLong.put(addressNumber,
- new String[] { latitude, longitude });
+ if (parts[6].length() > 0 && parts[7].length() > 0) {
+ addressNumberLatLong.put(addressNumber,
+ new String[] { parts[6], parts[7] });
+ }
}
} catch (NumberFormatException e) {
System.err.println("Number format exception while parsing line "
More information about the tor-commits
mailing list