@@ -88,7 +88,7 @@ private void indexPoints() throws IOException {
88
88
double y = (r .getMaxY () + r .getMinY ()) / 2 ;
89
89
for (int i = 0 ; i < 30 ; i += 10 ) {
90
90
for (int j = 0 ; j <= i ; j ++) {
91
- final Request putRequest = new Request (HttpPost .METHOD_NAME , INDEX_POINTS + "/_doc" );
91
+ final Request putRequest = new Request (HttpPost .METHOD_NAME , INDEX_POINTS + "/_doc/ " );
92
92
putRequest .setJsonEntity (
93
93
"{\n "
94
94
+ " \" location\" : \" POINT("
@@ -117,10 +117,10 @@ private void indexPoints() throws IOException {
117
117
118
118
private void indexShapes () throws IOException {
119
119
final Rectangle r = GeoTileUtils .toBoundingBox (x , y , z );
120
- createIndexAndPutGeometry (INDEX_POLYGON , toPolygon (r ));
120
+ createIndexAndPutGeometry (INDEX_POLYGON , toPolygon (r ), "polygon" );
121
121
}
122
122
123
- private void createIndexAndPutGeometry (String indexName , Geometry geometry ) throws IOException {
123
+ private void createIndexAndPutGeometry (String indexName , Geometry geometry , String id ) throws IOException {
124
124
final Request createRequest = new Request (HttpPut .METHOD_NAME , indexName );
125
125
Response response = client ().performRequest (createRequest );
126
126
assertThat (response .getStatusLine ().getStatusCode (), Matchers .equalTo (HttpStatus .SC_OK ));
@@ -140,7 +140,7 @@ private void createIndexAndPutGeometry(String indexName, Geometry geometry) thro
140
140
response = client ().performRequest (mappingRequest );
141
141
assertThat (response .getStatusLine ().getStatusCode (), Matchers .equalTo (HttpStatus .SC_OK ));
142
142
143
- final Request putRequest = new Request (HttpPost .METHOD_NAME , indexName + "/_doc" );
143
+ final Request putRequest = new Request (HttpPost .METHOD_NAME , indexName + "/_doc/" + id );
144
144
putRequest .setJsonEntity (
145
145
"{\n "
146
146
+ " \" location\" : \" "
@@ -249,7 +249,7 @@ public void testBasicGet() throws Exception {
249
249
mvtRequest .setJsonEntity ("{\" size\" : 100}" );
250
250
final VectorTile .Tile tile = execute (mvtRequest );
251
251
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
252
- assertLayer (tile , HITS_LAYER , 4096 , 33 , 1 );
252
+ assertLayer (tile , HITS_LAYER , 4096 , 33 , 2 );
253
253
assertLayer (tile , AGGS_LAYER , 4096 , 1 , 1 );
254
254
assertLayer (tile , META_LAYER , 4096 , 1 , 13 );
255
255
}
@@ -260,7 +260,7 @@ public void testIndexAllGet() throws Exception {
260
260
final VectorTile .Tile tile = execute (mvtRequest );
261
261
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
262
262
// 33 points, 1 polygon and two from geometry collection
263
- assertLayer (tile , HITS_LAYER , 4096 , 36 , 1 );
263
+ assertLayer (tile , HITS_LAYER , 4096 , 36 , 2 );
264
264
assertLayer (tile , AGGS_LAYER , 4096 , 256 * 256 , 1 );
265
265
assertLayer (tile , META_LAYER , 4096 , 1 , 13 );
266
266
}
@@ -270,7 +270,7 @@ public void testExtent() throws Exception {
270
270
mvtRequest .setJsonEntity ("{\" size\" : 100, \" extent\" : 256}" );
271
271
final VectorTile .Tile tile = execute (mvtRequest );
272
272
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
273
- assertLayer (tile , HITS_LAYER , 256 , 33 , 1 );
273
+ assertLayer (tile , HITS_LAYER , 256 , 33 , 2 );
274
274
assertLayer (tile , AGGS_LAYER , 256 , 1 , 1 );
275
275
assertLayer (tile , META_LAYER , 256 , 1 , 13 );
276
276
}
@@ -283,7 +283,7 @@ public void testExtentURL() throws Exception {
283
283
mvtRequest .setJsonEntity ("{\" size\" : 100, \" extent\" : 256}" );
284
284
final VectorTile .Tile tile = execute (mvtRequest );
285
285
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
286
- assertLayer (tile , HITS_LAYER , 512 , 33 , 1 );
286
+ assertLayer (tile , HITS_LAYER , 512 , 33 , 2 );
287
287
assertLayer (tile , AGGS_LAYER , 512 , 1 , 1 );
288
288
assertLayer (tile , META_LAYER , 512 , 1 , 13 );
289
289
}
@@ -339,7 +339,7 @@ public void testGridPrecision() throws Exception {
339
339
mvtRequest .setJsonEntity ("{\" size\" : 100, \" grid_precision\" : 7 }" );
340
340
final VectorTile .Tile tile = execute (mvtRequest );
341
341
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
342
- assertLayer (tile , HITS_LAYER , 4096 , 33 , 1 );
342
+ assertLayer (tile , HITS_LAYER , 4096 , 33 , 2 );
343
343
assertLayer (tile , AGGS_LAYER , 4096 , 1 , 1 );
344
344
assertLayer (tile , META_LAYER , 4096 , 1 , 13 );
345
345
}
@@ -357,7 +357,7 @@ public void testGridType() throws Exception {
357
357
mvtRequest .setJsonEntity ("{\" size\" : 100, \" grid_type\" : \" point\" }" );
358
358
final VectorTile .Tile tile = execute (mvtRequest );
359
359
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
360
- assertLayer (tile , HITS_LAYER , 4096 , 33 , 1 );
360
+ assertLayer (tile , HITS_LAYER , 4096 , 33 , 2 );
361
361
assertLayer (tile , AGGS_LAYER , 4096 , 1 , 1 );
362
362
assertLayer (tile , META_LAYER , 4096 , 1 , 13 );
363
363
assertFeatureType (tile , AGGS_LAYER , VectorTile .Tile .GeomType .POINT );
@@ -367,7 +367,7 @@ public void testGridType() throws Exception {
367
367
mvtRequest .setJsonEntity ("{\" size\" : 100, \" grid_type\" : \" grid\" }" );
368
368
final VectorTile .Tile tile = execute (mvtRequest );
369
369
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
370
- assertLayer (tile , HITS_LAYER , 4096 , 33 , 1 );
370
+ assertLayer (tile , HITS_LAYER , 4096 , 33 , 2 );
371
371
assertLayer (tile , AGGS_LAYER , 4096 , 1 , 1 );
372
372
assertLayer (tile , META_LAYER , 4096 , 1 , 13 );
373
373
assertFeatureType (tile , AGGS_LAYER , VectorTile .Tile .GeomType .POLYGON );
@@ -388,7 +388,7 @@ public void testGridTypeURL() throws Exception {
388
388
mvtRequest .setJsonEntity ("{\" size\" : 100, \" grid_type\" : \" point\" }" );
389
389
final VectorTile .Tile tile = execute (mvtRequest );
390
390
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
391
- assertLayer (tile , HITS_LAYER , 4096 , 33 , 1 );
391
+ assertLayer (tile , HITS_LAYER , 4096 , 33 , 2 );
392
392
assertLayer (tile , AGGS_LAYER , 4096 , 1 , 1 );
393
393
assertLayer (tile , META_LAYER , 4096 , 1 , 13 );
394
394
assertFeatureType (tile , AGGS_LAYER , VectorTile .Tile .GeomType .POLYGON );
@@ -399,7 +399,7 @@ public void testNoAggLayer() throws Exception {
399
399
mvtRequest .setJsonEntity ("{\" size\" : 100, \" grid_precision\" : 0 }" );
400
400
final VectorTile .Tile tile = execute (mvtRequest );
401
401
assertThat (tile .getLayersCount (), Matchers .equalTo (2 ));
402
- assertLayer (tile , HITS_LAYER , 4096 , 33 , 1 );
402
+ assertLayer (tile , HITS_LAYER , 4096 , 33 , 2 );
403
403
assertLayer (tile , META_LAYER , 4096 , 1 , 8 );
404
404
}
405
405
@@ -411,7 +411,7 @@ public void testNoAggLayerURL() throws Exception {
411
411
mvtRequest .setJsonEntity ("{\" size\" : 100, \" grid_precision\" : 4 }" );
412
412
final VectorTile .Tile tile = execute (mvtRequest );
413
413
assertThat (tile .getLayersCount (), Matchers .equalTo (2 ));
414
- assertLayer (tile , HITS_LAYER , 4096 , 33 , 1 );
414
+ assertLayer (tile , HITS_LAYER , 4096 , 33 , 2 );
415
415
assertLayer (tile , META_LAYER , 4096 , 1 , 8 );
416
416
}
417
417
@@ -439,7 +439,7 @@ public void testDefaultSort() throws Exception {
439
439
mvtRequest .setJsonEntity ("{\" size\" : 100 }" );
440
440
final VectorTile .Tile tile = execute (mvtRequest );
441
441
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
442
- assertLayer (tile , HITS_LAYER , 4096 , 34 , 1 );
442
+ assertLayer (tile , HITS_LAYER , 4096 , 34 , 2 );
443
443
final VectorTile .Tile .Layer layer = getLayer (tile , HITS_LAYER );
444
444
assertThat (layer .getFeatures (0 ).getType (), Matchers .equalTo (VectorTile .Tile .GeomType .POLYGON ));
445
445
assertLayer (tile , AGGS_LAYER , 4096 , 256 * 256 , 1 );
@@ -450,7 +450,7 @@ public void testDefaultSort() throws Exception {
450
450
mvtRequest .setJsonEntity ("{\" size\" : 100, \" sort\" : []}" ); // override default sort
451
451
final VectorTile .Tile tile = execute (mvtRequest );
452
452
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
453
- assertLayer (tile , HITS_LAYER , 4096 , 34 , 1 );
453
+ assertLayer (tile , HITS_LAYER , 4096 , 34 , 2 );
454
454
final VectorTile .Tile .Layer layer = getLayer (tile , HITS_LAYER );
455
455
assertThat (layer .getFeatures (0 ).getType (), Matchers .equalTo (VectorTile .Tile .GeomType .POINT ));
456
456
assertLayer (tile , AGGS_LAYER , 4096 , 256 * 256 , 1 );
@@ -487,7 +487,7 @@ public void testRuntimeFieldWithSort() throws Exception {
487
487
488
488
final VectorTile .Tile tile = execute (mvtRequest );
489
489
assertThat (tile .getLayersCount (), Matchers .equalTo (2 ));
490
- assertLayer (tile , HITS_LAYER , 4096 , 34 , 1 );
490
+ assertLayer (tile , HITS_LAYER , 4096 , 34 , 2 );
491
491
final VectorTile .Tile .Layer layer = getLayer (tile , HITS_LAYER );
492
492
assertThat (layer .getFeatures (0 ).getType (), Matchers .equalTo (VectorTile .Tile .GeomType .POLYGON ));
493
493
assertLayer (tile , META_LAYER , 4096 , 1 , 8 );
@@ -513,7 +513,7 @@ public void testRuntimeFieldWithSort() throws Exception {
513
513
514
514
final VectorTile .Tile tile = execute (mvtRequest );
515
515
assertThat (tile .getLayersCount (), Matchers .equalTo (2 ));
516
- assertLayer (tile , HITS_LAYER , 4096 , 34 , 1 );
516
+ assertLayer (tile , HITS_LAYER , 4096 , 34 , 2 );
517
517
final VectorTile .Tile .Layer layer = getLayer (tile , HITS_LAYER );
518
518
assertThat (layer .getFeatures (33 ).getType (), Matchers .equalTo (VectorTile .Tile .GeomType .POLYGON ));
519
519
assertLayer (tile , META_LAYER , 4096 , 1 , 8 );
@@ -535,26 +535,29 @@ public void testBasicQueryGet() throws Exception {
535
535
);
536
536
final VectorTile .Tile tile = execute (mvtRequest );
537
537
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
538
- assertLayer (tile , HITS_LAYER , 4096 , 1 , 1 );
538
+ assertLayer (tile , HITS_LAYER , 4096 , 1 , 2 );
539
539
assertLayer (tile , AGGS_LAYER , 4096 , 1 , 1 );
540
540
assertLayer (tile , META_LAYER , 4096 , 1 , 13 );
541
+ assertStringTag (getLayer (tile , HITS_LAYER ), getLayer (tile , HITS_LAYER ).getFeatures (0 ), "_index" , INDEX_POINTS );
541
542
}
542
543
543
544
public void testBasicShape () throws Exception {
544
545
final Request mvtRequest = new Request (getHttpMethod (), INDEX_POLYGON + "/_mvt/location/" + z + "/" + x + "/" + y );
545
546
final VectorTile .Tile tile = execute (mvtRequest );
546
547
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
547
- assertLayer (tile , HITS_LAYER , 4096 , 1 , 1 );
548
+ assertLayer (tile , HITS_LAYER , 4096 , 1 , 2 );
548
549
assertLayer (tile , AGGS_LAYER , 4096 , 256 * 256 , 1 );
549
550
assertLayer (tile , META_LAYER , 4096 , 1 , 13 );
551
+ assertStringTag (getLayer (tile , HITS_LAYER ), getLayer (tile , HITS_LAYER ).getFeatures (0 ), "_index" , INDEX_POLYGON );
552
+ assertStringTag (getLayer (tile , HITS_LAYER ), getLayer (tile , HITS_LAYER ).getFeatures (0 ), "_id" , "polygon" );
550
553
}
551
554
552
555
public void testWithFields () throws Exception {
553
556
final Request mvtRequest = new Request (getHttpMethod (), INDEX_POLYGON + "/_mvt/location/" + z + "/" + x + "/" + y );
554
557
mvtRequest .setJsonEntity ("{\" fields\" : [\" name\" , \" value1\" ] }" );
555
558
final VectorTile .Tile tile = execute (mvtRequest );
556
559
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
557
- assertLayer (tile , HITS_LAYER , 4096 , 1 , 3 );
560
+ assertLayer (tile , HITS_LAYER , 4096 , 1 , 4 );
558
561
assertLayer (tile , AGGS_LAYER , 4096 , 256 * 256 , 1 );
559
562
assertLayer (tile , META_LAYER , 4096 , 1 , 13 );
560
563
}
@@ -574,13 +577,13 @@ public void testMinAgg() throws Exception {
574
577
);
575
578
final VectorTile .Tile tile = execute (mvtRequest );
576
579
assertThat (tile .getLayersCount (), Matchers .equalTo (3 ));
577
- assertLayer (tile , HITS_LAYER , 4096 , 1 , 1 );
580
+ assertLayer (tile , HITS_LAYER , 4096 , 1 , 2 );
578
581
assertLayer (tile , AGGS_LAYER , 4096 , 256 * 256 , 2 );
579
582
assertLayer (tile , META_LAYER , 4096 , 1 , 18 );
580
583
// check pipeline aggregation values
581
584
final VectorTile .Tile .Layer metaLayer = getLayer (tile , META_LAYER );
582
- assertTag (metaLayer , metaLayer .getFeatures (0 ), "aggregations.minVal.min" , 1.0 );
583
- assertTag (metaLayer , metaLayer .getFeatures (0 ), "aggregations.minVal.max" , 1.0 );
585
+ assertDoubleTag (metaLayer , metaLayer .getFeatures (0 ), "aggregations.minVal.min" , 1.0 );
586
+ assertDoubleTag (metaLayer , metaLayer .getFeatures (0 ), "aggregations.minVal.max" , 1.0 );
584
587
}
585
588
586
589
public void testOverlappingMultipolygon () throws Exception {
@@ -589,7 +592,7 @@ public void testOverlappingMultipolygon() throws Exception {
589
592
final String index = "overlapping_multipolygon" ;
590
593
final Rectangle r1 = new Rectangle (-160 , 160 , 80 , -80 );
591
594
final Rectangle r2 = new Rectangle (-159 , 161 , 79 , -81 );
592
- createIndexAndPutGeometry (index , new MultiPolygon (List .of (toPolygon (r1 ), toPolygon (r2 ))));
595
+ createIndexAndPutGeometry (index , new MultiPolygon (List .of (toPolygon (r1 ), toPolygon (r2 ))), "multi_polygon" );
593
596
final Request mvtRequest = new Request (getHttpMethod (), index + "/_mvt/location/0/0/0?grid_precision=0" );
594
597
final VectorTile .Tile tile = execute (mvtRequest );
595
598
assertThat (tile .getLayersCount (), Matchers .equalTo (2 ));
@@ -618,7 +621,7 @@ private void assertLayer(VectorTile.Tile tile, String name, int extent, int numF
618
621
assertThat (layer .getKeysCount (), Matchers .equalTo (numTags ));
619
622
}
620
623
621
- private void assertTag (VectorTile .Tile .Layer layer , VectorTile .Tile .Feature feature , String tag , double value ) {
624
+ private void assertDoubleTag (VectorTile .Tile .Layer layer , VectorTile .Tile .Feature feature , String tag , double value ) {
622
625
for (int i = 0 ; i < feature .getTagsCount (); i += 2 ) {
623
626
String thisTag = layer .getKeys (feature .getTags (i ));
624
627
if (tag .equals (thisTag )) {
@@ -630,6 +633,16 @@ private void assertTag(VectorTile.Tile.Layer layer, VectorTile.Tile.Feature feat
630
633
fail ("Could not find tag [" + tag + " ]" );
631
634
}
632
635
636
+ private void assertStringTag (VectorTile .Tile .Layer layer , VectorTile .Tile .Feature feature , String tag , String value ) {
637
+ for (int i = 0 ; i < feature .getTagsCount (); i += 2 ) {
638
+ String thisTag = layer .getKeys (feature .getTags (i ));
639
+ if (tag .equals (thisTag )) {
640
+ VectorTile .Tile .Value thisValue = layer .getValues (feature .getTags (i + 1 ));
641
+ assertEquals (thisValue .getStringValue (), value );
642
+ }
643
+ }
644
+ }
645
+
633
646
private VectorTile .Tile execute (Request mvtRequest ) throws IOException {
634
647
final Response response = client ().performRequest (mvtRequest );
635
648
final InputStream inputStream = response .getEntity ().getContent ();
0 commit comments