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

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

import java.io.IOException;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.SerializerProvider;
import org.codehaus.jackson.map.ser.std.SerializerBase;

import com.vividsolutions.jts.geom.Point;

public class GisPointSerializer extends SerializerBase<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);
		}
	}
}
