18
18
*/
19
19
package org .elasticsearch .common .geo ;
20
20
21
- import org .apache .lucene .util .BytesRef ;
22
21
import org .elasticsearch .common .geo .builders .ShapeBuilder ;
22
+ import org .elasticsearch .common .io .stream .BytesStreamOutput ;
23
+ import org .elasticsearch .common .io .stream .StreamInput ;
23
24
import org .elasticsearch .geo .geometry .Polygon ;
24
25
import org .elasticsearch .test .ESTestCase ;
25
26
import org .elasticsearch .test .geo .RandomShapeGenerator ;
@@ -38,8 +39,10 @@ public void testRectangleShape() throws IOException {
38
39
int [] x = new int []{minX , maxX , maxX , minX , minX };
39
40
int [] y = new int []{minY , minY , maxY , maxY , minY };
40
41
EdgeTreeWriter writer = new EdgeTreeWriter (x , y );
41
- BytesRef bytes = writer .toBytesRef ();
42
- EdgeTreeReader reader = new EdgeTreeReader (bytes );
42
+ BytesStreamOutput output = new BytesStreamOutput ();
43
+ writer .writeTo (output );
44
+ output .close ();
45
+ EdgeTreeReader reader = new EdgeTreeReader (StreamInput .wrap (output .bytes ().toBytesRef ().bytes ));
43
46
44
47
// box-query touches bottom-left corner
45
48
assertTrue (reader .containedInOrCrosses (minX - randomIntBetween (1 , 180 ), minY - randomIntBetween (1 , 180 ), minX , minY ));
@@ -93,7 +96,10 @@ public void testSimplePolygon() throws IOException {
93
96
int [] y = asIntArray (geo .getPolygon ().getLats ());
94
97
95
98
EdgeTreeWriter writer = new EdgeTreeWriter (x , y );
96
- EdgeTreeReader reader = new EdgeTreeReader (writer .toBytesRef ());
99
+ BytesStreamOutput output = new BytesStreamOutput ();
100
+ writer .writeTo (output );
101
+ output .close ();
102
+ EdgeTreeReader reader = new EdgeTreeReader (StreamInput .wrap (output .bytes ().toBytesRef ().bytes ));
97
103
// polygon fully contained within box
98
104
assertTrue (reader .containedInOrCrosses (minXBox , minYBox , maxXBox , maxYBox ));
99
105
// containedInOrCrosses
@@ -121,7 +127,10 @@ public void testPacMan() throws Exception {
121
127
122
128
// test cell crossing poly
123
129
EdgeTreeWriter writer = new EdgeTreeWriter (px , py );
124
- EdgeTreeReader reader = new EdgeTreeReader (writer .toBytesRef ());
130
+ BytesStreamOutput output = new BytesStreamOutput ();
131
+ writer .writeTo (output );
132
+ output .close ();
133
+ EdgeTreeReader reader = new EdgeTreeReader (StreamInput .wrap (output .bytes ().toBytesRef ().bytes ));
125
134
assertTrue (reader .containsBottomLeft (xMin , yMin , xMax , yMax ));
126
135
}
127
136
0 commit comments