Skip to content
Snippets Groups Projects
Commit 25d9725b authored by Powers, Peter M.'s avatar Powers, Peter M.
Browse files

geojson 269 update

parent d30c85f9
No related branches found
No related tags found
1 merge request!270Deagg by source, hazout, and geojson
...@@ -95,21 +95,22 @@ public final class GeoJson { ...@@ -95,21 +95,22 @@ public final class GeoJson {
key, value, actual); 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"; String type = "FeatureCollection";
List<Feature> features; public Object properties;
public List<T> features;
} }
static class Feature { public static class Feature {
String type = "Feature"; String type = "Feature";
String id; String id;
Geometry geometry = new Geometry(); Geometry geometry = new Geometry();
PropertiesObject properties; PropertiesObject properties;
} }
static Feature createPoint(NamedLocation loc) { public static Feature createPoint(NamedLocation loc) {
Feature f = new Feature(); Feature f = new Feature();
f.geometry.type = "Point"; f.geometry.type = "Point";
f.geometry.coordinates = toCoordinates(loc.location()); f.geometry.coordinates = toCoordinates(loc.location());
...@@ -118,6 +119,16 @@ public final class GeoJson { ...@@ -118,6 +119,16 @@ public final class GeoJson {
return f; 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"; private static final String EXTENTS_COLOR = "#AA0078";
static Feature createPolygon( static Feature createPolygon(
...@@ -154,6 +165,8 @@ public final class GeoJson { ...@@ -154,6 +165,8 @@ public final class GeoJson {
static class PropertiesObject { static class PropertiesObject {
String title; String title;
String location;
String locationId;
} }
static class PointProperties extends PropertiesObject { static class PointProperties extends PropertiesObject {
...@@ -182,7 +195,7 @@ public final class GeoJson { ...@@ -182,7 +195,7 @@ public final class GeoJson {
} }
/* brute force compaction of coordinate array onto single line */ /* brute force compaction of coordinate array onto single line */
static String cleanPoints(String s) { public static String cleanPoints(String s) {
return s.replace(": [\n ", ": [") return s.replace(": [\n ", ": [")
.replace(",\n ", ", ") .replace(",\n ", ", ")
.replace("\n ]", "]") + "\n"; .replace("\n ]", "]") + "\n";
...@@ -197,5 +210,4 @@ public final class GeoJson { ...@@ -197,5 +210,4 @@ public final class GeoJson {
.replace("\n ]", " ]") .replace("\n ]", " ]")
.replace("\n ]", "]") + "\n"; .replace("\n ]", "]") + "\n";
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment