You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/12/11 20:58:37 UTC
[13/27] lucene-solr:jira/http2: LUCENE-8587: Change GeoPoint
serialization to make serialization/unserialization non-lossy
LUCENE-8587: Change GeoPoint serialization to make serialization/unserialization non-lossy
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/da62c732
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/da62c732
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/da62c732
Branch: refs/heads/jira/http2
Commit: da62c732822f891102820f6b3efb054012f18b1c
Parents: 05d728f
Author: Karl Wright <Da...@gmail.com>
Authored: Tue Dec 11 09:30:01 2018 -0500
Committer: Karl Wright <Da...@gmail.com>
Committed: Tue Dec 11 09:30:01 2018 -0500
----------------------------------------------------------------------
.../apache/lucene/spatial3d/geom/GeoPoint.java | 34 ++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/da62c732/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java
index 66c6226..e058fe7 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java
@@ -77,12 +77,39 @@ public class GeoPoint extends Vector implements SerializableObject {
this(planetModel, Math.sin(lat), Math.sin(lon), Math.cos(lat), Math.cos(lon), lat, lon);
}
- /** Construct a GeoPoint from a planet model and an input stream.
+ /** Construct a GeoPoint from an input stream.
+ * @param planetModel is the planet model
+ * @param inputStream is the input stream
*/
public GeoPoint(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(inputStream);
+ }
+
+ /** Construct a GeoPoint from an input stream with no planet model.
+ * @param inputStream is the input stream
+ */
+ public GeoPoint(final InputStream inputStream) throws IOException {
// Note: this relies on left-right parameter execution order!! Much code depends on that though and
// it is apparently in a java spec: https://stackoverflow.com/questions/2201688/order-of-execution-of-parameters-guarantees-in-java
- this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ this(SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ /** Construct a GeoPoint from five unchecked parameters: lat, lon, x, y, z. This is primarily used for deserialization,
+ * but can also be used to fully initialize a point externally.
+ * @param lat is the latitude in radians
+ * @param lon is the longitude in radians
+ * @param x is the unit x value
+ * @param y is the unit y value
+ * @param z is the unit z value
+ */
+ public GeoPoint(final double lat, final double lon, final double x, final double y, final double z) {
+ super(x, y, z);
+ this.latitude = lat;
+ this.longitude = lon;
}
/** Construct a GeoPoint from a unit (x,y,z) vector and a magnitude.
@@ -131,6 +158,9 @@ public class GeoPoint extends Vector implements SerializableObject {
public void write(final OutputStream outputStream) throws IOException {
SerializableObject.writeDouble(outputStream, getLatitude());
SerializableObject.writeDouble(outputStream, getLongitude());
+ SerializableObject.writeDouble(outputStream, x);
+ SerializableObject.writeDouble(outputStream, y);
+ SerializableObject.writeDouble(outputStream, z);
}
/** Compute an arc distance between two points.