suerprisePlus
2024-09-04 85af9acfccf2e944a97557d3e46d143b0e99e2f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.yb.postgis;
 
import java.io.IOException;
 
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.locationtech.jts.geom.Geometry;
 
 
/**
 * Serializing Geometry property as WKT String with Jackson<br>
 *
 * @param <T>
 * @author guyadong
 */
public class GeometrySerializer<T extends Geometry> extends JsonSerializer<T> {
 
    @Override
    public void serialize(T value, JsonGenerator gen, SerializerProvider serializers)
            throws IOException, JsonProcessingException {
        gen.writeString(value.toText());
    }
}