LUCENE-8964: Fix geojson shape parsing on string arrays in properties (#866)

This commit is contained in:
Alexander Reelsen 2019-09-10 14:15:28 +02:00 committed by iverase
parent 4af601eb10
commit bb5f4ddd75
3 changed files with 22 additions and 0 deletions

View File

@ -70,6 +70,9 @@ Improvements
* LUCENE-8620: Tessellator labels the edges of the generated triangles whether they belong to * LUCENE-8620: Tessellator labels the edges of the generated triangles whether they belong to
the original polygon. This information is added to the triangle encoding. (Ignacio Vera) the original polygon. This information is added to the triangle encoding. (Ignacio Vera)
* LUCENE-8964: Fix geojson shape parsing on string arrays in properties
(Alexander Reelsen)
Optimizations Optimizations
* LUCENE-8922: DisjunctionMaxQuery more efficiently leverages impacts to skip * LUCENE-8922: DisjunctionMaxQuery more efficiently leverages impacts to skip

View File

@ -295,6 +295,8 @@ class SimpleGeoJSONPolygonParser {
o = null; o = null;
} else if (ch == '-' || ch == '.' || (ch >= '0' && ch <= '9')) { } else if (ch == '-' || ch == '.' || (ch >= '0' && ch <= '9')) {
o = parseNumber(); o = parseNumber();
} else if (ch == '"') {
o = parseString();
} else { } else {
throw newParseException("expected another array or number while parsing array, not '" + ch + "'"); throw newParseException("expected another array or number while parsing array, not '" + ch + "'");
} }

View File

@ -300,4 +300,21 @@ public class TestPolygon extends LuceneTestCase {
Exception e = expectThrows(ParseException.class, () -> Polygon.fromGeoJSON(b.toString())); Exception e = expectThrows(ParseException.class, () -> Polygon.fromGeoJSON(b.toString()));
assertTrue(e.getMessage().contains("can only handle type FeatureCollection (if it has a single polygon geometry), Feature, Polygon or MutiPolygon, but got Point")); assertTrue(e.getMessage().contains("can only handle type FeatureCollection (if it has a single polygon geometry), Feature, Polygon or MutiPolygon, but got Point"));
} }
public void testPolygonPropertiesCanBeStringArrays() throws Exception {
StringBuilder b = new StringBuilder();
b.append("{\n");
b.append(" \"type\": \"Polygon\",\n");
b.append(" \"coordinates\": [\n");
b.append(" [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],\n");
b.append(" [100.0, 1.0], [100.0, 0.0] ]\n");
b.append(" ],\n");
b.append(" \"properties\": {\n");
b.append(" \"array\": [ \"value\" ]\n");
b.append(" }\n");
b.append("}\n");
Polygon[] polygons = Polygon.fromGeoJSON(b.toString());
assertEquals(1, polygons.length);
}
} }