Created
January 13, 2020 19:37
-
-
Save bigalnz/3ff012cb445179fead670292ebc6cad8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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