diff --git a/src/gov/usgs/earthquake/nshmp/internal/GeoJson.java b/src/gov/usgs/earthquake/nshmp/internal/GeoJson.java index a5d190256323df4d2b67985e02202e5137e0ca97..8944ecc8a888befce3a9853d42448a83ff6bd1fe 100644 --- a/src/gov/usgs/earthquake/nshmp/internal/GeoJson.java +++ b/src/gov/usgs/earthquake/nshmp/internal/GeoJson.java @@ -95,21 +95,22 @@ public final class GeoJson { key, value, actual); } - /* GeoJSON objectsfor stadard GSON serialization */ + /* GeoJSON objects for standard GSON serialization */ - static class FeatureCollection { + public static class FeatureCollection<T> { String type = "FeatureCollection"; - List<Feature> features; + public Object properties; + public List<T> features; } - static class Feature { + public static class Feature { String type = "Feature"; String id; Geometry geometry = new Geometry(); PropertiesObject properties; } - static Feature createPoint(NamedLocation loc) { + public static Feature createPoint(NamedLocation loc) { Feature f = new Feature(); f.geometry.type = "Point"; f.geometry.coordinates = toCoordinates(loc.location()); @@ -118,6 +119,16 @@ public final class GeoJson { return f; } + public static Feature createPoint(NamedLocation loc, String id) { + Feature f = new Feature(); + f.geometry.type = "Point"; + f.geometry.coordinates = toCoordinates(loc.location()); + f.properties = new PropertiesObject(); + f.properties.location = loc.toString(); + f.properties.locationId = id; + return f; + } + private static final String EXTENTS_COLOR = "#AA0078"; static Feature createPolygon( @@ -154,6 +165,8 @@ public final class GeoJson { static class PropertiesObject { String title; + String location; + String locationId; } static class PointProperties extends PropertiesObject { @@ -182,7 +195,7 @@ public final class GeoJson { } /* brute force compaction of coordinate array onto single line */ - static String cleanPoints(String s) { + public static String cleanPoints(String s) { return s.replace(": [\n ", ": [") .replace(",\n ", ", ") .replace("\n ]", "]") + "\n"; @@ -197,5 +210,4 @@ public final class GeoJson { .replace("\n ]", " ]") .replace("\n ]", "]") + "\n"; } - }