Created
January 13, 2020 19:21
-
-
Save bigalnz/ba1cb1286cde917391892cd43a6da5d9 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); | |
// 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(p, 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