mirror of https://github.com/apache/lucene.git
LUCENE-8964: Fix geojson shape parsing on string arrays in properties (#866)
This commit is contained in:
parent
4af601eb10
commit
bb5f4ddd75
|
@ -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
|
||||||
|
|
|
@ -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 + "'");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue