-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added buffer pixels to vector tile spec parsing (#84710)
* Added buffer pixels to vector tile spec parsing Previously this was hard-coded to 5, but now is configurable using the format z/x/y@extent:buffer, where both extent and buffer are optional and default to 4096 and 5 pixels respectively. Co-authored-by: James Rodewig <james.rodewig@elastic.co>
- Loading branch information
1 parent
94f7d73
commit 397eccf
Showing
9 changed files
with
195 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 84710 | ||
summary: Added buffer pixels to vector tile spec parsing | ||
area: Geo | ||
type: enhancement | ||
issues: | ||
- 84492 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
server/src/test/java/org/elasticsearch/common/geo/SimpleVectorTileFormatterTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.common.geo; | ||
|
||
import org.elasticsearch.test.ESTestCase; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class SimpleVectorTileFormatterTests extends ESTestCase { | ||
|
||
public void testEmptyString() { | ||
var exception = expectThrows(IllegalArgumentException.class, () -> SimpleVectorTileFormatter.parse("")); | ||
assertThat(exception.getMessage(), containsString("Invalid mvt formatter parameter")); | ||
} | ||
|
||
public void testInvalid() { | ||
var exception = expectThrows(IllegalArgumentException.class, () -> SimpleVectorTileFormatter.parse("invalid")); | ||
assertThat(exception.getMessage(), containsString("Invalid mvt formatter parameter")); | ||
} | ||
|
||
public void testInvalidCombination() { | ||
var exception = expectThrows(IllegalArgumentException.class, () -> SimpleVectorTileFormatter.parse("1/2/3")); | ||
assertThat(exception.getMessage(), containsString("Zoom/X/Y combination is not valid")); | ||
} | ||
|
||
public void testLeadingWhitespace() { | ||
var exception = expectThrows(IllegalArgumentException.class, () -> SimpleVectorTileFormatter.parse(" 2/1/0")); | ||
assertThat(exception.getMessage(), containsString("Invalid mvt formatter parameter")); | ||
} | ||
|
||
public void testTrailingWhitespace() { | ||
var exception = expectThrows(IllegalArgumentException.class, () -> SimpleVectorTileFormatter.parse("2/1/0 ")); | ||
assertThat(exception.getMessage(), containsString("Invalid mvt formatter parameter")); | ||
} | ||
|
||
public void testValidSimple() { | ||
int[] fields = SimpleVectorTileFormatter.parse("2/1/0"); | ||
assertThat(fields.length, equalTo(5)); | ||
assertThat(fields[0], equalTo(2)); | ||
assertThat(fields[1], equalTo(1)); | ||
assertThat(fields[2], equalTo(0)); | ||
assertThat(fields[3], equalTo(SimpleVectorTileFormatter.DEFAULT_EXTENT)); | ||
assertThat(fields[4], equalTo(SimpleVectorTileFormatter.DEFAULT_BUFFER_PIXELS)); | ||
} | ||
|
||
public void testValidWithExtent() { | ||
int[] fields = SimpleVectorTileFormatter.parse("2/1/0@5000"); | ||
assertThat(fields.length, equalTo(5)); | ||
assertThat(fields[0], equalTo(2)); | ||
assertThat(fields[1], equalTo(1)); | ||
assertThat(fields[2], equalTo(0)); | ||
assertThat(fields[3], equalTo(5000)); | ||
assertThat(fields[4], equalTo(SimpleVectorTileFormatter.DEFAULT_BUFFER_PIXELS)); | ||
} | ||
|
||
public void testInvalidExtent() { | ||
var exception = expectThrows(IllegalArgumentException.class, () -> SimpleVectorTileFormatter.parse("2/1/0@invalid")); | ||
assertThat(exception.getMessage(), containsString("Invalid mvt formatter parameter")); | ||
} | ||
|
||
public void testInvalidExtentValue() { | ||
var exception = expectThrows(IllegalArgumentException.class, () -> SimpleVectorTileFormatter.parse("2/1/0@0")); | ||
assertThat(exception.getMessage(), containsString("Extent is not valid")); | ||
} | ||
|
||
public void testValidWithExtentAndBuffer() { | ||
int[] fields = SimpleVectorTileFormatter.parse("2/1/0@5000:55"); | ||
assertThat(fields.length, equalTo(5)); | ||
assertThat(fields[0], equalTo(2)); | ||
assertThat(fields[1], equalTo(1)); | ||
assertThat(fields[2], equalTo(0)); | ||
assertThat(fields[3], equalTo(5000)); | ||
assertThat(fields[4], equalTo(55)); | ||
} | ||
|
||
public void testValidWithBuffer() { | ||
int[] fields = SimpleVectorTileFormatter.parse("2/1/0:55"); | ||
assertThat(fields.length, equalTo(5)); | ||
assertThat(fields[0], equalTo(2)); | ||
assertThat(fields[1], equalTo(1)); | ||
assertThat(fields[2], equalTo(0)); | ||
assertThat(fields[3], equalTo(SimpleVectorTileFormatter.DEFAULT_EXTENT)); | ||
assertThat(fields[4], equalTo(55)); | ||
} | ||
|
||
public void testInvalidBuffer() { | ||
var exception = expectThrows(IllegalArgumentException.class, () -> SimpleVectorTileFormatter.parse("2/1/0:invalid")); | ||
assertThat(exception.getMessage(), containsString("Invalid mvt formatter parameter")); | ||
} | ||
|
||
public void testInvalidBufferValue() { | ||
var exception = expectThrows(IllegalArgumentException.class, () -> SimpleVectorTileFormatter.parse("2/1/0:-1")); | ||
assertThat(exception.getMessage(), containsString("Invalid mvt formatter parameter")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.