diff --git a/src/main/java/net/frozenorb/apiv3/model/IpIntel.java b/src/main/java/net/frozenorb/apiv3/model/IpIntel.java index 4c85887..1bdf0e4 100644 --- a/src/main/java/net/frozenorb/apiv3/model/IpIntel.java +++ b/src/main/java/net/frozenorb/apiv3/model/IpIntel.java @@ -140,11 +140,7 @@ public final class IpIntel { this.hashedIp = Hashing.sha256().hashString(id + APIv3.getConfig().getProperty("ipHashing.salt"), Charsets.UTF_8).toString(); this.lastUpdatedAt = Instant.now(); this.result = result; - - if (result.getLocation() != null) { - MaxMindLocation location = result.getLocation(); - this.location = new GeoJsonPoint(location.getLongitude(), location.getLatitude()); - } + this.location = new GeoJsonPoint(result.getLocation()); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/util/GeoJsonPoint.java b/src/main/java/net/frozenorb/apiv3/util/GeoJsonPoint.java index 5267000..b82605d 100644 --- a/src/main/java/net/frozenorb/apiv3/util/GeoJsonPoint.java +++ b/src/main/java/net/frozenorb/apiv3/util/GeoJsonPoint.java @@ -1,5 +1,7 @@ package net.frozenorb.apiv3.util; +import net.frozenorb.apiv3.maxmind.MaxMindLocation; + public final class GeoJsonPoint { private String type = "Point"; @@ -7,6 +9,10 @@ public final class GeoJsonPoint { private GeoJsonPoint() {} // For Jackson + public GeoJsonPoint(MaxMindLocation maxMindLocation) { + this(maxMindLocation.getLongitude(), maxMindLocation.getLatitude()); + } + public GeoJsonPoint(double longitude, double latitude) { this.coordinates = new double[] { longitude, latitude}; }