Cleanup geospatial code a tiny bit

This commit is contained in:
Colin McDonald 2016-08-18 13:46:49 -04:00
parent a3d1812b83
commit 95944d023d
2 changed files with 7 additions and 5 deletions

View File

@ -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());
}
}

View File

@ -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};
}