Skip to content

Instantly share code, notes, and snippets.

@bigalnz
Created January 13, 2020 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigalnz/3ff012cb445179fead670292ebc6cad8 to your computer and use it in GitHub Desktop.
Save bigalnz/3ff012cb445179fead670292ebc6cad8 to your computer and use it in GitHub Desktop.
GeometryFactory gf = new GeometryFactory();
Double y = -36.829;
Double x = 174.896;
Task testTask = new Task();
testTask.setId(new Long(01));
testTask.setTitle("Test Task");
Point p = gf.createPoint(new Coordinate(x, y));
p.setSRID(4326);
testTask.setLocation(p);
taskRepository.save(testTask);
ObjectMapper objectMapper = new ObjectMapper();
String geoJson = objectMapper.writeValueAsString(testTask);
System.out.println(geoJson);
GeoJSONWriter writer = new GeoJSONWriter();
GeoJSON json = writer.write(p);
// create and serialize a FeatureCollection
List<Feature> features = new ArrayList<Feature>();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("Size", 5);
properties.put("Area", "Auckland");
features.add(new Feature( this needs org.wololo.geojson.Geometry, properties));
GeoJSONWriter writer = new GeoJSONWriter();
GeoJson json = writer.write(features);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment