Jackson deserialize GeoJson Point in Spring Boot

前端 未结 3 1825
日久生厌
日久生厌 2020-12-18 06:27

I have a @Entity model that has a property of type com.vividsolutions.jts.geom.Point. When I try to render this model in a @RestController

3条回答
  •  离开以前
    2020-12-18 07:00

    The above workaround using JTSModule results in an internal SpringBoot error for me. I was able to solve this issue by making sure the getter methods of my Entity are returning String types.

    @Entity
    public class MyClassWithGeom {
    
        @Id
        @GeneratedValue
        private Long id;
        private Point centre;
        private Polygon boundary;
    
        private MyClassWithGeom() {}
    
        public MyClassWithGeom(String centreLat, String centreLng, Double[]... boundaryCoords) {
            String wkt = "POINT (" + centreLat + " " + centreLng + ")";
            StringBuilder builder = new StringBuilder("POLYGON (( ");
    
            for(int i=0;i

提交回复
热议问题