package it.mice.voila.runtime.hibernatespatial.serializers;

import it.mice.voila.runtime.hibernatespatial.JsonPoint;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

import com.vividsolutions.jts.geom.Point;

public class GisPointSerializer extends StdSerializer<Point> {
	public GisPointSerializer() {
		super(Point.class, true);
	}

	@Override
	public void serialize(Point value, JsonGenerator jgen,
			SerializerProvider provider) throws IOException,
			JsonGenerationException {

		if (value != null) {
			JsonPoint jsonPoint = new JsonPoint(value);
			jgen.writeObject(jsonPoint);
		}
	}
}
