1 package org.geojson.jackson; 2 3 import java.io.IOException; 4 5 import org.geojson.LngLatAlt; 6 7 import com.fasterxml.jackson.core.JsonGenerator; 8 import com.fasterxml.jackson.databind.JsonSerializer; 9 import com.fasterxml.jackson.databind.SerializerProvider; 10 11 public class LngLatAltSerializer extends JsonSerializer<LngLatAlt> { 12 13 @Override serialize(LngLatAlt value, JsonGenerator jgen, SerializerProvider provider)14 public void serialize(LngLatAlt value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 15 jgen.writeStartArray(); 16 jgen.writeNumber(value.getLongitude()); 17 jgen.writeNumber(value.getLatitude()); 18 if (value.hasAltitude()) { 19 jgen.writeNumber(value.getAltitude()); 20 21 for (double d : value.getAdditionalElements()) { 22 jgen.writeNumber(d); 23 } 24 } 25 jgen.writeEndArray(); 26 } 27 } 28