diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java index 1b412bb774b..5e53ae452ea 100644 --- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java +++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java @@ -31,6 +31,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.text.StringAndBytesText; import org.elasticsearch.common.text.Text; import org.joda.time.DateTime; @@ -420,11 +421,17 @@ public abstract class StreamInput extends InputStream { return readDoubleArray(); case 21: return readBytesRef(); + case 22: + return readGeoPoint(); default: throw new IOException("Can't read unknown type [" + type + "]"); } } + public GeoPoint readGeoPoint() throws IOException { + return new GeoPoint(readDouble(), readDouble()); + } + public int[] readIntArray() throws IOException { int length = readVInt(); int[] values = new int[length]; diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java index 9621d049b6a..563f4a1fd0f 100644 --- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java +++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java @@ -30,6 +30,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.text.Text; import org.joda.time.ReadableInstant; @@ -408,6 +409,10 @@ public abstract class StreamOutput extends OutputStream { } else if (value instanceof BytesRef) { writeByte((byte) 21); writeBytesRef((BytesRef) value); + } else if (type == GeoPoint.class) { + writeByte((byte) 22); + writeDouble(((GeoPoint) value).lat()); + writeDouble(((GeoPoint) value).lon()); } else { throw new IOException("Can't write type [" + type + "]"); }