com.graphhopper.jackson.GHPointSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphhopper-web-api Show documentation
Show all versions of graphhopper-web-api Show documentation
JSON Representation of the API classes
package com.graphhopper.jackson;
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 com.graphhopper.util.shapes.GHPoint;
import java.io.IOException;
class GHPointSerializer extends JsonSerializer {
@Override
public void serialize(GHPoint ghPoint, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
jsonGenerator.writeStartArray();
for (Double number : ghPoint.toGeoJson()) {
jsonGenerator.writeNumber(number);
}
jsonGenerator.writeEndArray();
}
}