You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2017/08/24 17:41:46 UTC
[1/2] lucene-solr:master: LUCENE-7936: Implement
serialization/deserialization for all objects except GeoComplexPolygon and
composites.
Repository: lucene-solr
Updated Branches:
refs/heads/master f9cc10928 -> 7f5292035
LUCENE-7936: Implement serialization/deserialization for all objects except GeoComplexPolygon and composites.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/fd11646a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/fd11646a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/fd11646a
Branch: refs/heads/master
Commit: fd11646af2da0302a315e77e3caa3e254681a2f9
Parents: 6b8f98d
Author: Karl Wright <Da...@gmail.com>
Authored: Thu Aug 24 13:41:22 2017 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Thu Aug 24 13:41:22 2017 -0400
----------------------------------------------------------------------
.../lucene/spatial3d/geom/BasePlanetObject.java | 2 +-
.../spatial3d/geom/GeoConcavePolygon.java | 23 ++
.../lucene/spatial3d/geom/GeoConvexPolygon.java | 23 ++
.../geom/GeoDegenerateHorizontalLine.java | 20 ++
.../geom/GeoDegenerateLatitudeZone.java | 18 ++
.../geom/GeoDegenerateLongitudeSlice.java | 18 ++
.../geom/GeoDegenerateVerticalLine.java | 20 ++
.../lucene/spatial3d/geom/GeoLatitudeZone.java | 19 ++
.../spatial3d/geom/GeoLongitudeSlice.java | 19 ++
.../spatial3d/geom/GeoNorthLatitudeZone.java | 18 ++
.../spatial3d/geom/GeoNorthRectangle.java | 20 ++
.../lucene/spatial3d/geom/GeoRectangle.java | 21 ++
.../spatial3d/geom/GeoSouthLatitudeZone.java | 18 ++
.../spatial3d/geom/GeoSouthRectangle.java | 20 ++
.../spatial3d/geom/GeoStandardCircle.java | 23 ++
.../lucene/spatial3d/geom/GeoStandardPath.java | 23 +-
.../geom/GeoWideDegenerateHorizontalLine.java | 20 ++
.../spatial3d/geom/GeoWideLongitudeSlice.java | 19 ++
.../spatial3d/geom/GeoWideNorthRectangle.java | 24 ++
.../lucene/spatial3d/geom/GeoWideRectangle.java | 26 +++
.../spatial3d/geom/GeoWideSouthRectangle.java | 24 ++
.../apache/lucene/spatial3d/geom/GeoWorld.java | 17 ++
.../lucene/spatial3d/geom/PlanetObject.java | 2 +-
.../spatial3d/geom/SerializableObject.java | 221 +++++++++++++++++--
.../lucene/spatial3d/geom/StandardXYZSolid.java | 49 ++++
.../apache/lucene/spatial3d/geom/XYdZSolid.java | 44 ++++
.../apache/lucene/spatial3d/geom/XdYZSolid.java | 44 ++++
.../lucene/spatial3d/geom/XdYdZSolid.java | 39 ++++
.../apache/lucene/spatial3d/geom/dXYZSolid.java | 44 ++++
.../lucene/spatial3d/geom/dXYdZSolid.java | 39 ++++
.../lucene/spatial3d/geom/dXdYZSolid.java | 39 ++++
.../lucene/spatial3d/geom/dXdYdZSolid.java | 35 +++
32 files changed, 967 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/BasePlanetObject.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/BasePlanetObject.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/BasePlanetObject.java
index 86ec61f..bb2cc31 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/BasePlanetObject.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/BasePlanetObject.java
@@ -25,7 +25,7 @@ import java.io.IOException;
*
* @lucene.internal
*/
-public abstract class BasePlanetObject implements PlanetObject, SerializableObject {
+public abstract class BasePlanetObject implements PlanetObject {
/** This is the planet model embedded in all objects derived from this
* class. */
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
index 75fecc8..7e4ef28 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
@@ -21,6 +21,9 @@ import java.util.BitSet;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
/**
* GeoConcavePolygon objects are generic building blocks of more complex structures.
@@ -302,6 +305,26 @@ class GeoConcavePolygon extends GeoBasePolygon {
return index;
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoConcavePolygon(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ super(planetModel);
+ this.points = java.util.Arrays.asList(SerializableObject.readPointArray(planetModel, inputStream));
+ this.holes = java.util.Arrays.asList(SerializableObject.readPolygonArray(planetModel, inputStream));
+ this.isInternalEdges = SerializableObject.readBitSet(inputStream);
+ done(this.isInternalEdges.get(points.size()-1));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writePointArray(outputStream, points);
+ SerializableObject.writePolygonArray(outputStream, holes);
+ SerializableObject.writeBitSet(outputStream, isInternalEdges);
+ }
+
@Override
public boolean isWithin(final double x, final double y, final double z) {
if (!localIsWithin(x, y, z)) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
index bf75e3b..9711d81 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
@@ -21,6 +21,9 @@ import java.util.BitSet;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
/**
* GeoConvexPolygon objects are generic building blocks of more complex structures.
@@ -298,6 +301,26 @@ class GeoConvexPolygon extends GeoBasePolygon {
return index;
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoConvexPolygon(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ super(planetModel);
+ this.points = java.util.Arrays.asList(SerializableObject.readPointArray(planetModel, inputStream));
+ this.holes = java.util.Arrays.asList(SerializableObject.readPolygonArray(planetModel, inputStream));
+ this.isInternalEdges = SerializableObject.readBitSet(inputStream);
+ done(this.isInternalEdges.get(points.size()-1));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writePointArray(outputStream, points);
+ SerializableObject.writePolygonArray(outputStream, holes);
+ SerializableObject.writeBitSet(outputStream, isInternalEdges);
+ }
+
@Override
public boolean isWithin(final double x, final double y, final double z) {
if (!localIsWithin(x, y, z)) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java
index 9518180..9be5b37 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Degenerate bounding box limited on two sides (left lon, right lon).
* The left-right maximum extent for this shape is PI; for anything larger, use
@@ -108,6 +112,22 @@ class GeoDegenerateHorizontalLine extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{centerPoint};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoDegenerateHorizontalLine(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, latitude);
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
double newTopLat = latitude + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java
index fc6b234..aa87981 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* This GeoBBox represents an area rectangle of one specific latitude with
* no longitude bounds.
@@ -52,6 +56,20 @@ class GeoDegenerateLatitudeZone extends GeoBaseBBox {
edgePoints = new GeoPoint[]{interiorPoint};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoDegenerateLatitudeZone(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, latitude);
+ }
+
@Override
public GeoBBox expand(final double angle) {
double newTopLat = latitude + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java
index e610ff4..0d30335 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Degenerate longitude slice.
*
@@ -57,6 +61,20 @@ class GeoDegenerateLongitudeSlice extends GeoBaseBBox {
this.planePoints = new GeoPoint[]{planetModel.NORTH_POLE, planetModel.SOUTH_POLE};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoDegenerateLongitudeSlice(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, longitude);
+ }
+
@Override
public GeoBBox expand(final double angle) {
// Figuring out when we escalate to a special case requires some prefiguring
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java
index c8acf78..22c0928 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Degenerate bounding box limited on two sides (top lat, bottom lat).
*
@@ -97,6 +101,22 @@ public class GeoDegenerateVerticalLine extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{centerPoint};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoDegenerateVerticalLine(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, topLat);
+ SerializableObject.writeDouble(outputStream, bottomLat);
+ SerializableObject.writeDouble(outputStream, longitude);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = topLat + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java
index 716efb5..8db77ed 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* This GeoBBox represents an area rectangle limited only in latitude.
*
@@ -77,6 +81,21 @@ class GeoLatitudeZone extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{topBoundaryPoint, bottomBoundaryPoint};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoLatitudeZone(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, topLat);
+ SerializableObject.writeDouble(outputStream, bottomLat);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = topLat + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
index fc21a21..404bf8c 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Bounding box limited on left and right.
* The left-right maximum extent for this shape is PI; for anything larger, use
@@ -81,6 +85,21 @@ class GeoLongitudeSlice extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{planetModel.NORTH_POLE};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoLongitudeSlice(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
// Figuring out when we escalate to a special case requires some prefiguring
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java
index 7c3ea96..4371126 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* This GeoBBox represents an area rectangle limited only in south latitude.
*
@@ -59,6 +63,20 @@ class GeoNorthLatitudeZone extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{bottomBoundaryPoint};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoNorthLatitudeZone(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, bottomLat);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = Math.PI * 0.5;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
index 2a1b7c5..1dac929 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Bounding box limited on three sides (bottom lat, left lon, right lon), including
* the north pole.
@@ -116,6 +120,22 @@ class GeoNorthRectangle extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{planetModel.NORTH_POLE};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoNorthRectangle(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, bottomLat);
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = Math.PI * 0.5;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
index faf2952..7e98214 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Bounding box limited on four sides (top lat, bottom lat, left lon, right lon).
* The left-right maximum extent for this shape is PI; for anything larger, use
@@ -142,6 +146,23 @@ class GeoRectangle extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{ULHC};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoRectangle(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, topLat);
+ SerializableObject.writeDouble(outputStream, bottomLat);
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = topLat + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java
index acb7cb0..4b6a549 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* This GeoBBox represents an area rectangle limited only in north latitude.
*
@@ -59,6 +63,20 @@ class GeoSouthLatitudeZone extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{topBoundaryPoint};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoSouthLatitudeZone(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, topLat);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = topLat + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
index f75fc8c..a23b927 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Bounding box limited on three sides (top lat, left lon, right lon). The
* other corner is the south pole.
@@ -121,6 +125,22 @@ class GeoSouthRectangle extends GeoBaseBBox {
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoSouthRectangle(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, topLat);
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = topLat + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java
index ec83edf..acba9f5 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Circular area with a center and radius.
*
@@ -91,6 +95,25 @@ class GeoStandardCircle extends GeoBaseCircle {
}
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoStandardCircle(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, center.getLatitude());
+ SerializableObject.writeDouble(outputStream, center.getLongitude());
+ SerializableObject.writeDouble(outputStream, cutoffAngle);
+ }
+
@Override
public double getRadius() {
return cutoffAngle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
index b3b6594..c30414c 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -63,7 +67,7 @@ class GeoStandardPath extends GeoBasePath {
Collections.addAll(points, pathPoints);
done();
}
-
+
/** Piece-wise constructor. Use in conjunction with addPoint() and done().
*@param planetModel is the planet model.
*@param maxCutoffAngle is the width of the path, measured as an angle.
@@ -193,6 +197,23 @@ class GeoStandardPath extends GeoBasePath {
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoStandardPath(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readPointArray(planetModel, inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, cutoffAngle);
+ SerializableObject.writePointArray(outputStream, points);
+ }
+
@Override
protected double distance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
// Algorithm:
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java
index 90d35ee..b22ce0f 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Degenerate bounding box wider than PI and limited on two sides (left lon, right lon).
*
@@ -114,6 +118,22 @@ class GeoWideDegenerateHorizontalLine extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{centerPoint};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoWideDegenerateHorizontalLine(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, latitude);
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = latitude + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java
index e15c275..adf03d8 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Bounding box wider than PI but limited on left and right sides (
* left lon, right lon).
@@ -91,6 +95,21 @@ class GeoWideLongitudeSlice extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{planetModel.NORTH_POLE};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoWideLongitudeSlice(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
// Figuring out when we escalate to a special case requires some prefiguring
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java
index 5672003..7d0ccad 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Bounding box wider than PI but limited on three sides (
* bottom lat, left lon, right lon).
@@ -64,6 +68,10 @@ class GeoWideNorthRectangle extends GeoBaseBBox {
/**
* Accepts only values in the following ranges: lat: {@code -PI/2 -> PI/2}, lon: {@code -PI -> PI}.
* Horizontal angle must be greater than or equal to PI.
+ * @param planetModel is the planet model.
+ * @param bottomLat is the bottom latitude.
+ * @param leftLon is the left longitude.
+ * @param rightLon is the right longitude.
*/
public GeoWideNorthRectangle(final PlanetModel planetModel, final double bottomLat, final double leftLon, double rightLon) {
super(planetModel);
@@ -121,6 +129,22 @@ class GeoWideNorthRectangle extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{planetModel.NORTH_POLE};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoWideNorthRectangle(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, bottomLat);
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = Math.PI * 0.5;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java
index 43b9bc7..b200e0c 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Bounding box wider than PI but limited on four sides (top lat,
* bottom lat, left lon, right lon).
@@ -74,6 +78,11 @@ class GeoWideRectangle extends GeoBaseBBox {
/**
* Accepts only values in the following ranges: lat: {@code -PI/2 -> PI/2}, lon: {@code -PI -> PI}.
* Horizontal angle must be greater than or equal to PI.
+ * @param planetModel is the planet model.
+ * @param topLat is the top latitude.
+ * @param bottomLat is the bottom latitude.
+ * @param leftLon is the left longitude.
+ * @param rightLon is the right longitude.
*/
public GeoWideRectangle(final PlanetModel planetModel, final double topLat, final double bottomLat, final double leftLon, double rightLon) {
super(planetModel);
@@ -143,6 +152,23 @@ class GeoWideRectangle extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{ULHC};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoWideRectangle(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, topLat);
+ SerializableObject.writeDouble(outputStream, bottomLat);
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = topLat + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java
index ea60322..eca4f62 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Bounding box wider than PI but limited on three sides (top lat,
* left lon, right lon).
@@ -64,6 +68,10 @@ class GeoWideSouthRectangle extends GeoBaseBBox {
/**
* Accepts only values in the following ranges: lat: {@code -PI/2 -> PI/2}, lon: {@code -PI -> PI}.
* Horizontal angle must be greater than or equal to PI.
+ * @param planetModel is the planet model.
+ * @param topLat is the top latitude.
+ * @param leftLon is the left longitude.
+ * @param rightLon is the right longitude.
*/
public GeoWideSouthRectangle(final PlanetModel planetModel, final double topLat, final double leftLon, double rightLon) {
super(planetModel);
@@ -122,6 +130,22 @@ class GeoWideSouthRectangle extends GeoBaseBBox {
this.edgePoints = new GeoPoint[]{planetModel.SOUTH_POLE};
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public GeoWideSouthRectangle(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel, SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream), SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, topLat);
+ SerializableObject.writeDouble(outputStream, leftLon);
+ SerializableObject.writeDouble(outputStream, rightLon);
+ }
+
@Override
public GeoBBox expand(final double angle) {
final double newTopLat = topLat + angle;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java
index ebe11db..641f09d 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* Bounding box including the entire world.
*
@@ -35,6 +39,19 @@ class GeoWorld extends GeoBaseBBox {
originPoint = new GeoPoint(planetModel.ab, 1.0, 0.0, 0.0);
}
+ /** Constructor.
+ *@param planetModel is the planet model.
+ *@param inputStream is the input stream.
+ */
+ public GeoWorld(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel);
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ // Nothing needed
+ }
+
@Override
public GeoBBox expand(final double angle) {
return this;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetObject.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetObject.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetObject.java
index 836bf4c..a0c175a 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetObject.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetObject.java
@@ -22,7 +22,7 @@ package org.apache.lucene.spatial3d.geom;
*
* @lucene.experimental
*/
-public interface PlanetObject {
+public interface PlanetObject extends SerializableObject {
/** Returns the {@link PlanetModel} provided when this shape was created. */
PlanetModel getPlanetModel();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SerializableObject.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SerializableObject.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SerializableObject.java
index 618ebaf..9479cf2 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SerializableObject.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SerializableObject.java
@@ -23,6 +23,8 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.BitSet;
/**
* Indicates that a geo3d object can be serialized and deserialized.
@@ -56,28 +58,40 @@ public interface SerializableObject {
try {
// Look for the class
final Class<?> clazz = Class.forName(className);
+ return readObject(planetModel, inputStream, clazz);
+ } catch (ClassNotFoundException e) {
+ throw new IOException("Can't find class "+className+" for deserialization: "+e.getMessage(), e);
+ }
+ }
+
+ /** Instantiate a serializable object from a stream.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ * @param clazz is the class to instantiate.
+ */
+ static SerializableObject readObject(final PlanetModel planetModel, final InputStream inputStream, final Class<?> clazz) throws IOException {
+ try {
// Look for the right constructor
final Constructor<?> c = clazz.getDeclaredConstructor(PlanetModel.class, InputStream.class);
// Invoke it
final Object object = c.newInstance(planetModel, inputStream);
// check whether caste will work
if (!(object instanceof SerializableObject)) {
- throw new IOException("Object "+className+" does not implement SerializableObject");
+ throw new IOException("Object "+clazz.getName()+" does not implement SerializableObject");
}
return (SerializableObject)object;
- } catch (ClassNotFoundException e) {
- throw new IOException("Can't find class "+className+" for deserialization: "+e.getMessage(), e);
} catch (InstantiationException e) {
- throw new IOException("Instantiation exception for class "+className+": "+e.getMessage(), e);
+ throw new IOException("Instantiation exception for class "+clazz.getName()+": "+e.getMessage(), e);
} catch (IllegalAccessException e) {
- throw new IOException("Illegal access creating class "+className+": "+e.getMessage(), e);
+ throw new IOException("Illegal access creating class "+clazz.getName()+": "+e.getMessage(), e);
} catch (NoSuchMethodException e) {
- throw new IOException("No such method exception for class "+className+": "+e.getMessage(), e);
+ throw new IOException("No such method exception for class "+clazz.getName()+": "+e.getMessage(), e);
} catch (InvocationTargetException e) {
- throw new IOException("Exception instantiating class "+className+": "+e.getMessage(), e);
+ throw new IOException("Exception instantiating class "+clazz.getName()+": "+e.getMessage(), e);
}
- }
+ }
+
/** Read an object from a stream (for objects that do not need a PlanetModel).
* @param inputStream is the input stream.
* @return the deserialized object.
@@ -88,36 +102,45 @@ public interface SerializableObject {
try {
// Look for the class
final Class<?> clazz = Class.forName(className);
+ return readObject(inputStream, clazz);
+ } catch (ClassNotFoundException e) {
+ throw new IOException("Can't find class "+className+" for deserialization: "+e.getMessage(), e);
+ }
+ }
+
+ /** Instantiate a serializable object from a stream without a planet model.
+ * @param inputStream is the input stream.
+ * @param clazz is the class to instantiate.
+ */
+ static SerializableObject readObject(final InputStream inputStream, final Class<?> clazz) throws IOException {
+ try {
// Look for the right constructor
final Constructor<?> c = clazz.getDeclaredConstructor(InputStream.class);
// Invoke it
final Object object = c.newInstance(inputStream);
// check whether caste will work
if (!(object instanceof SerializableObject)) {
- throw new IOException("Object "+className+" does not implement SerializableObject");
+ throw new IOException("Object "+clazz.getName()+" does not implement SerializableObject");
}
return (SerializableObject)object;
- } catch (ClassNotFoundException e) {
- throw new IOException("Can't find class "+className+" for deserialization: "+e.getMessage(), e);
} catch (InstantiationException e) {
- throw new IOException("Instantiation exception for class "+className+": "+e.getMessage(), e);
+ throw new IOException("Instantiation exception for class "+clazz.getName()+": "+e.getMessage(), e);
} catch (IllegalAccessException e) {
- throw new IOException("Illegal access creating class "+className+": "+e.getMessage(), e);
+ throw new IOException("Illegal access creating class "+clazz.getName()+": "+e.getMessage(), e);
} catch (NoSuchMethodException e) {
- throw new IOException("No such method exception for class "+className+": "+e.getMessage(), e);
+ throw new IOException("No such method exception for class "+clazz.getName()+": "+e.getMessage(), e);
} catch (InvocationTargetException e) {
- throw new IOException("Exception instantiating class "+className+": "+e.getMessage(), e);
+ throw new IOException("Exception instantiating class "+clazz.getName()+": "+e.getMessage(), e);
}
+
}
-
+
/** Write a string to a stream.
* @param outputStream is the output stream.
* @param value is the string to write.
*/
static void writeString(final OutputStream outputStream, final String value) throws IOException {
- final byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
- writeInt(outputStream, bytes.length);
- outputStream.write(bytes);
+ writeByteArray(outputStream, value.getBytes(StandardCharsets.UTF_8));
}
/** Read a string from a stream.
@@ -125,6 +148,162 @@ public interface SerializableObject {
* @return the string that was read.
*/
static String readString(final InputStream inputStream) throws IOException {
+ return new String(readByteArray(inputStream), StandardCharsets.UTF_8);
+ }
+
+ /** Write a point array.
+ * @param outputStream is the output stream.
+ * @param values is the array of points to write.
+ */
+ static void writePointArray(final OutputStream outputStream, final GeoPoint[] values) throws IOException {
+ writeHomogeneousArray(outputStream, values);
+ }
+
+ /** Write a point array.
+ * @param outputStream is the output stream.
+ * @param values is the list of points to write.
+ */
+ static void writePointArray(final OutputStream outputStream, final List<GeoPoint> values) throws IOException {
+ writeHomogeneousArray(outputStream, values);
+ }
+
+ /** Read a point array.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ * @return the array of points that was read.
+ */
+ static GeoPoint[] readPointArray(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ return (GeoPoint[])readHomogeneousArray(planetModel, inputStream, GeoPoint.class);
+ }
+
+ /** Write a polgon array.
+ * @param outputStream is the output stream.
+ * @param values is the array of points to write.
+ */
+ static void writePolygonArray(final OutputStream outputStream, final GeoPolygon[] values) throws IOException {
+ writeHeterogeneousArray(outputStream, values);
+ }
+
+ /** Write a polygon array.
+ * @param outputStream is the output stream.
+ * @param values is the list of points to write.
+ */
+ static void writePolygonArray(final OutputStream outputStream, final List<GeoPolygon> values) throws IOException {
+ writeHeterogeneousArray(outputStream, values);
+ }
+
+ /** Read a polygon array.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ * @return the array of polygons that was read.
+ */
+ static GeoPolygon[] readPolygonArray(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ return (GeoPolygon[])readHeterogeneousArray(planetModel, inputStream);
+ }
+
+ /** Write an array.
+ * @param outputStream is the output stream,.
+ * @param values is the array.
+ */
+ static void writeHomogeneousArray(final OutputStream outputStream, final SerializableObject[] values) throws IOException {
+ writeInt(outputStream, values.length);
+ for (final SerializableObject value : values) {
+ value.write(outputStream);
+ }
+ }
+
+ /** Write an array.
+ * @param outputStream is the output stream,.
+ * @param values is the array.
+ */
+ static void writeHomogeneousArray(final OutputStream outputStream, final List<? extends SerializableObject> values) throws IOException {
+ writeInt(outputStream, values.size());
+ for (final SerializableObject value : values) {
+ value.write(outputStream);
+ }
+ }
+
+ /** Read an array.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ * @param clazz is the class of the objects to read.
+ * @return the array.
+ */
+ static SerializableObject[] readHomogeneousArray(final PlanetModel planetModel, final InputStream inputStream, final Class<?> clazz) throws IOException {
+ final int count = readInt(inputStream);
+ final SerializableObject[] rval = new SerializableObject[count];
+ for (int i = 0; i < count; i++) {
+ rval[i] = readObject(planetModel, inputStream, clazz);
+ }
+ return rval;
+ }
+
+ /** Write an array.
+ * @param outputStream is the output stream,.
+ * @param values is the array.
+ */
+ static void writeHeterogeneousArray(final OutputStream outputStream, final SerializableObject[] values) throws IOException {
+ writeInt(outputStream, values.length);
+ for (final SerializableObject value : values) {
+ writeObject(outputStream, value);
+ }
+ }
+
+ /** Write an array.
+ * @param outputStream is the output stream,.
+ * @param values is the array.
+ */
+ static void writeHeterogeneousArray(final OutputStream outputStream, final List<? extends SerializableObject> values) throws IOException {
+ writeInt(outputStream, values.size());
+ for (final SerializableObject value : values) {
+ writeObject(outputStream, value);
+ }
+ }
+
+ /** Read an array.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ * @return the array.
+ */
+ static SerializableObject[] readHeterogeneousArray(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ final int count = readInt(inputStream);
+ final SerializableObject[] rval = new SerializableObject[count];
+ for (int i = 0; i < count; i++) {
+ rval[i] = readObject(planetModel, inputStream);
+ }
+ return rval;
+ }
+
+ /** Write a bitset to a stream.
+ * @param outputStream is the output stream.
+ * @param bitSet is the bit set to write.
+ */
+ static void writeBitSet(final OutputStream outputStream, final BitSet bitSet) throws IOException {
+ writeByteArray(outputStream, bitSet.toByteArray());
+ }
+
+ /** Read a bitset from a stream.
+ * @param inputStream is the input stream.
+ * @return the bitset read from the stream.
+ */
+ static BitSet readBitSet(final InputStream inputStream) throws IOException {
+ return BitSet.valueOf(readByteArray(inputStream));
+ }
+
+ /** Write byte array.
+ * @param outputStream is the output stream.
+ * @param bytes is the byte array.
+ */
+ static void writeByteArray(final OutputStream outputStream, final byte[] bytes) throws IOException {
+ writeInt(outputStream, bytes.length);
+ outputStream.write(bytes);
+ }
+
+ /** Read byte array.
+ * @param inputStream is the input stream.
+ * @return the byte array.
+ */
+ static byte[] readByteArray(final InputStream inputStream) throws IOException {
int stringLength = readInt(inputStream);
int stringOffset = 0;
final byte[] bytes = new byte[stringLength];
@@ -136,9 +315,9 @@ public interface SerializableObject {
stringOffset += amt;
stringLength -= amt;
}
- return new String(bytes, StandardCharsets.UTF_8);
+ return bytes;
}
-
+
/** Write a double to a stream.
* @param outputStream is the output stream.
* @param value is the value to write.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java
index 0f79f24..8ad21e6 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* 3D rectangle, bounded on six sides by X,Y,Z limits
*
@@ -23,6 +27,19 @@ package org.apache.lucene.spatial3d.geom;
*/
class StandardXYZSolid extends BaseXYZSolid {
+ /** Min-X */
+ protected final double minX;
+ /** Max-X */
+ protected final double maxX;
+ /** Min-Y */
+ protected final double minY;
+ /** Max-Y */
+ protected final double maxY;
+ /** Min-Z */
+ protected final double minZ;
+ /** Max-Z */
+ protected final double maxZ;
+
/** Whole world? */
protected final boolean isWholeWorld;
/** Min-X plane */
@@ -98,6 +115,13 @@ class StandardXYZSolid extends BaseXYZSolid {
if (maxZ - minZ < Vector.MINIMUM_RESOLUTION)
throw new IllegalArgumentException("Z values in wrong order or identical");
+ this.minX = minX;
+ this.maxX = maxX;
+ this.minY = minY;
+ this.maxY = maxY;
+ this.minZ = minZ;
+ this.maxZ = maxZ;
+
final double worldMinX = planetModel.getMinimumXValue();
final double worldMaxX = planetModel.getMaximumXValue();
final double worldMinY = planetModel.getMinimumYValue();
@@ -336,6 +360,31 @@ class StandardXYZSolid extends BaseXYZSolid {
}
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public StandardXYZSolid(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, minX);
+ SerializableObject.writeDouble(outputStream, maxX);
+ SerializableObject.writeDouble(outputStream, minY);
+ SerializableObject.writeDouble(outputStream, maxY);
+ SerializableObject.writeDouble(outputStream, minZ);
+ SerializableObject.writeDouble(outputStream, maxZ);
+ }
+
@Override
protected GeoPoint[] getEdgePoints() {
return edgePoints;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYdZSolid.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYdZSolid.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYdZSolid.java
index aa4b873..f5b2ae6 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYdZSolid.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYdZSolid.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* 3D rectangle, bounded on six sides by X,Y,Z limits, degenerate in Z
*
@@ -23,6 +27,17 @@ package org.apache.lucene.spatial3d.geom;
*/
class XYdZSolid extends BaseXYZSolid {
+ /** Min-X */
+ protected final double minX;
+ /** Max-X */
+ protected final double maxX;
+ /** Min-Y */
+ protected final double minY;
+ /** Max-Y */
+ protected final double maxY;
+ /** Z */
+ protected final double Z;
+
/** Min-X plane */
protected final SidedPlane minXPlane;
/** Max-X plane */
@@ -67,6 +82,12 @@ class XYdZSolid extends BaseXYZSolid {
if (maxY - minY < Vector.MINIMUM_RESOLUTION)
throw new IllegalArgumentException("Y values in wrong order or identical");
+ this.minX = minX;
+ this.maxX = maxX;
+ this.minY = minY;
+ this.maxY = maxY;
+ this.Z = Z;
+
final double worldMinZ = planetModel.getMinimumZValue();
final double worldMaxZ = planetModel.getMaximumZValue();
@@ -125,6 +146,29 @@ class XYdZSolid extends BaseXYZSolid {
this.edgePoints = glueTogether(minXZ, maxXZ, minYZ, maxYZ, zEdges);
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public XYdZSolid(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, minX);
+ SerializableObject.writeDouble(outputStream, maxX);
+ SerializableObject.writeDouble(outputStream, minY);
+ SerializableObject.writeDouble(outputStream, maxY);
+ SerializableObject.writeDouble(outputStream, Z);
+ }
+
@Override
protected GeoPoint[] getEdgePoints() {
return edgePoints;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYZSolid.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYZSolid.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYZSolid.java
index 37f2a46..3c11b4b 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYZSolid.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYZSolid.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* 3D rectangle, bounded on six sides by X,Y,Z limits, degenerate in Y
*
@@ -23,6 +27,17 @@ package org.apache.lucene.spatial3d.geom;
*/
class XdYZSolid extends BaseXYZSolid {
+ /** Min-X */
+ protected final double minX;
+ /** Max-X */
+ protected final double maxX;
+ /** Y */
+ protected final double Y;
+ /** Min-Z */
+ protected final double minZ;
+ /** Max-Z */
+ protected final double maxZ;
+
/** Min-X plane */
protected final SidedPlane minXPlane;
/** Max-X plane */
@@ -67,6 +82,12 @@ class XdYZSolid extends BaseXYZSolid {
if (maxZ - minZ < Vector.MINIMUM_RESOLUTION)
throw new IllegalArgumentException("Z values in wrong order or identical");
+ this.minX = minX;
+ this.maxX = maxX;
+ this.Y = Y;
+ this.minZ = minZ;
+ this.maxZ = maxZ;
+
final double worldMinY = planetModel.getMinimumYValue();
final double worldMaxY = planetModel.getMaximumYValue();
@@ -125,6 +146,29 @@ class XdYZSolid extends BaseXYZSolid {
this.edgePoints = glueTogether(minXY, maxXY, YminZ, YmaxZ, yEdges);
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public XdYZSolid(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, minX);
+ SerializableObject.writeDouble(outputStream, maxX);
+ SerializableObject.writeDouble(outputStream, Y);
+ SerializableObject.writeDouble(outputStream, minZ);
+ SerializableObject.writeDouble(outputStream, maxZ);
+ }
+
@Override
protected GeoPoint[] getEdgePoints() {
return edgePoints;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYdZSolid.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYdZSolid.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYdZSolid.java
index 936c184..7f0d9d1 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYdZSolid.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XdYdZSolid.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* 3D rectangle, bounded on six sides by X,Y,Z limits, degenerate in Y and Z.
* This figure, in fact, represents either zero, one, or two points, so the
@@ -25,6 +29,15 @@ package org.apache.lucene.spatial3d.geom;
*/
class XdYdZSolid extends BaseXYZSolid {
+ /** Min-X */
+ protected final double minX;
+ /** Max-X */
+ protected final double maxX;
+ /** Y */
+ protected final double Y;
+ /** Z */
+ protected final double Z;
+
/** The points in this figure on the planet surface; also doubles for edge points */
protected final GeoPoint[] surfacePoints;
@@ -47,6 +60,11 @@ class XdYdZSolid extends BaseXYZSolid {
if (maxX - minX < Vector.MINIMUM_RESOLUTION)
throw new IllegalArgumentException("X values in wrong order or identical");
+ this.minX = minX;
+ this.maxX = maxX;
+ this.Y = Y;
+ this.Z = Z;
+
// Build the planes and intersect them.
final Plane yPlane = new Plane(yUnitVector,-Y);
final Plane zPlane = new Plane(zUnitVector,-Z);
@@ -55,6 +73,27 @@ class XdYdZSolid extends BaseXYZSolid {
surfacePoints = yPlane.findIntersections(planetModel,zPlane,minXPlane,maxXPlane);
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public XdYdZSolid(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, minX);
+ SerializableObject.writeDouble(outputStream, maxX);
+ SerializableObject.writeDouble(outputStream, Y);
+ SerializableObject.writeDouble(outputStream, Z);
+ }
+
@Override
protected GeoPoint[] getEdgePoints() {
return surfacePoints;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYZSolid.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYZSolid.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYZSolid.java
index 029f215..e4f5ada 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYZSolid.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYZSolid.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* 3D rectangle, bounded on six sides by X,Y,Z limits, degenerate in X.
*
@@ -23,6 +27,17 @@ package org.apache.lucene.spatial3d.geom;
*/
class dXYZSolid extends BaseXYZSolid {
+ /** X */
+ protected final double X;
+ /** Min-Y */
+ protected final double minY;
+ /** Max-Y */
+ protected final double maxY;
+ /** Min-Z */
+ protected final double minZ;
+ /** Max-Z */
+ protected final double maxZ;
+
/** X plane */
protected final Plane xPlane;
/** Min-Y plane */
@@ -67,6 +82,12 @@ class dXYZSolid extends BaseXYZSolid {
if (maxZ - minZ < Vector.MINIMUM_RESOLUTION)
throw new IllegalArgumentException("Z values in wrong order or identical");
+ this.X = X;
+ this.minY = minY;
+ this.maxY = maxY;
+ this.minZ = minZ;
+ this.maxZ = maxZ;
+
final double worldMinX = planetModel.getMinimumXValue();
final double worldMaxX = planetModel.getMaximumXValue();
@@ -126,6 +147,29 @@ class dXYZSolid extends BaseXYZSolid {
this.edgePoints = glueTogether(XminY,XmaxY,XminZ,XmaxZ,xEdges);
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public dXYZSolid(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, X);
+ SerializableObject.writeDouble(outputStream, minY);
+ SerializableObject.writeDouble(outputStream, maxY);
+ SerializableObject.writeDouble(outputStream, minZ);
+ SerializableObject.writeDouble(outputStream, maxZ);
+ }
+
@Override
protected GeoPoint[] getEdgePoints() {
return edgePoints;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYdZSolid.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYdZSolid.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYdZSolid.java
index a1b5e96..0587bc2 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYdZSolid.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXYdZSolid.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* 3D rectangle, bounded on six sides by X,Y,Z limits, degenerate in X and Z.
* This figure, in fact, represents either zero, one, or two points, so the
@@ -25,6 +29,15 @@ package org.apache.lucene.spatial3d.geom;
*/
class dXYdZSolid extends BaseXYZSolid {
+ /** X */
+ protected final double X;
+ /** Min-Y */
+ protected final double minY;
+ /** Max-Y */
+ protected final double maxY;
+ /** Z */
+ protected final double Z;
+
/** The points in this figure on the planet surface; also doubles for edge points */
protected final GeoPoint[] surfacePoints;
@@ -47,6 +60,11 @@ class dXYdZSolid extends BaseXYZSolid {
if (maxY - minY < Vector.MINIMUM_RESOLUTION)
throw new IllegalArgumentException("Y values in wrong order or identical");
+ this.X = X;
+ this.minY = minY;
+ this.maxY = maxY;
+ this.Z = Z;
+
// Build the planes and intersect them.
final Plane xPlane = new Plane(xUnitVector,-X);
final Plane zPlane = new Plane(zUnitVector,-Z);
@@ -55,6 +73,27 @@ class dXYdZSolid extends BaseXYZSolid {
surfacePoints = xPlane.findIntersections(planetModel,zPlane,minYPlane,maxYPlane);
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public dXYdZSolid(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, X);
+ SerializableObject.writeDouble(outputStream, minY);
+ SerializableObject.writeDouble(outputStream, maxY);
+ SerializableObject.writeDouble(outputStream, Z);
+ }
+
@Override
protected GeoPoint[] getEdgePoints() {
return surfacePoints;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYZSolid.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYZSolid.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYZSolid.java
index 869ddea..3dfa6ec 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYZSolid.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYZSolid.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* 3D rectangle, bounded on six sides by X,Y,Z limits, degenerate in X and Y.
* This figure, in fact, represents either zero, one, or two points, so the
@@ -25,6 +29,15 @@ package org.apache.lucene.spatial3d.geom;
*/
class dXdYZSolid extends BaseXYZSolid {
+ /** X */
+ protected final double X;
+ /** Y */
+ protected final double Y;
+ /** Min-Z */
+ protected final double minZ;
+ /** Max-Z */
+ protected final double maxZ;
+
/** The points in this figure on the planet surface; also doubles for edge points */
protected final GeoPoint[] surfacePoints;
@@ -47,6 +60,11 @@ class dXdYZSolid extends BaseXYZSolid {
if (maxZ - minZ < Vector.MINIMUM_RESOLUTION)
throw new IllegalArgumentException("Z values in wrong order or identical");
+ this.X = X;
+ this.Y = Y;
+ this.minZ = minZ;
+ this.maxZ = maxZ;
+
// Build the planes and intersect them.
final Plane xPlane = new Plane(xUnitVector,-X);
final Plane yPlane = new Plane(yUnitVector,-Y);
@@ -55,6 +73,27 @@ class dXdYZSolid extends BaseXYZSolid {
surfacePoints = xPlane.findIntersections(planetModel,yPlane,minZPlane,maxZPlane);
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public dXdYZSolid(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, X);
+ SerializableObject.writeDouble(outputStream, Y);
+ SerializableObject.writeDouble(outputStream, minZ);
+ SerializableObject.writeDouble(outputStream, maxZ);
+ }
+
@Override
protected GeoPoint[] getEdgePoints() {
return surfacePoints;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd11646a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYdZSolid.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYdZSolid.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYdZSolid.java
index b647658..61b2608 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYdZSolid.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/dXdYdZSolid.java
@@ -16,6 +16,10 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
/**
* 3D rectangle, bounded on six sides by X,Y,Z limits, degenerate in all dimensions
*
@@ -23,6 +27,13 @@ package org.apache.lucene.spatial3d.geom;
*/
class dXdYdZSolid extends BaseXYZSolid {
+ /** X */
+ protected final double X;
+ /** Y */
+ protected final double Y;
+ /** Z */
+ protected final double Z;
+
/** On surface? */
protected final boolean isOnSurface;
/** The point */
@@ -51,6 +62,11 @@ class dXdYdZSolid extends BaseXYZSolid {
final double Y,
final double Z) {
super(planetModel);
+
+ this.X = X;
+ this.Y = Y;
+ this.Z = Z;
+
isOnSurface = planetModel.pointOnSurface(X,Y,Z);
if (isOnSurface) {
thePoint = new GeoPoint(X,Y,Z);
@@ -61,6 +77,25 @@ class dXdYdZSolid extends BaseXYZSolid {
}
}
+ /**
+ * Constructor for deserialization.
+ * @param planetModel is the planet model.
+ * @param inputStream is the input stream.
+ */
+ public dXdYdZSolid(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
+ this(planetModel,
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream),
+ SerializableObject.readDouble(inputStream));
+ }
+
+ @Override
+ public void write(final OutputStream outputStream) throws IOException {
+ SerializableObject.writeDouble(outputStream, X);
+ SerializableObject.writeDouble(outputStream, Y);
+ SerializableObject.writeDouble(outputStream, Z);
+ }
+
@Override
protected GeoPoint[] getEdgePoints() {
return edgePoints;
[2/2] lucene-solr:master: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by kw...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/lucene-solr
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/7f529203
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7f529203
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7f529203
Branch: refs/heads/master
Commit: 7f52920352de39c39f05b1f10951cb84ab7b8bd0
Parents: fd11646 f9cc109
Author: Karl Wright <Da...@gmail.com>
Authored: Thu Aug 24 13:41:34 2017 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Thu Aug 24 13:41:34 2017 -0400
----------------------------------------------------------------------
lucene/CHANGES.txt | 6 +++
.../lucene/search/MinShouldMatchSumScorer.java | 51 +++++++++++++++++++-
.../analyzing/AnalyzingInfixSuggester.java | 14 ++++--
solr/CHANGES.txt | 4 ++
.../LTRFeatureLoggerTransformerFactory.java | 13 ++++-
.../handler/component/RealTimeGetComponent.java | 4 +-
.../solr/handler/component/TermsComponent.java | 2 +-
.../org/apache/solr/response/DocsStreamer.java | 6 ++-
.../transform/BaseEditorialTransformer.java | 2 +-
.../transform/ChildDocTransformerFactory.java | 2 +-
.../transform/DocIdAugmenterFactory.java | 2 +-
.../solr/response/transform/DocTransformer.java | 18 ++++++-
.../response/transform/DocTransformers.java | 7 +++
.../transform/ExplainAugmenterFactory.java | 2 +-
.../transform/GeoTransformerFactory.java | 4 +-
.../transform/RawValueTransformerFactory.java | 2 +-
.../transform/RenameFieldTransformer.java | 2 +-
.../solr/response/transform/ScoreAugmenter.java | 5 ++
.../transform/SubQueryAugmenterFactory.java | 2 +-
.../transform/ValueAugmenterFactory.java | 2 +-
.../transform/ValueSourceAugmenter.java | 2 +-
.../solr/response/TestCustomDocTransformer.java | 2 +-
.../shards-and-indexing-data-in-solrcloud.adoc | 4 +-
23 files changed, 133 insertions(+), 25 deletions(-)
----------------------------------------------------------------------