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 коммит произвёл Ignacio Vera
Родитель 4599f6e9ee
Коммит 5f6c744ae1
3 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -56,6 +56,9 @@ Improvements
* LUCENE-8937: Avoid agressive stemming on numbers in the FrenchMinimalStemmer.
(Adrien Gallou via Tomoko Uchida)
* LUCENE-8964: Fix geojson shape parsing on string arrays in properties
(Alexander Reelsen)
Bug fixes
* LUCENE-8663: NRTCachingDirectory.slowFileExists may open a file while

Просмотреть файл

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

Просмотреть файл

@ -300,4 +300,21 @@ public class TestPolygon extends LuceneTestCase {
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"));
}
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);
}
}