Make sure a LineString has at least two points
According to the GeoJSON specification [1]: > For type "LineString", the "coordinates" member is an array of two or > more positions. Note that the same doesn't seem to apply to a MultiPoint [2]: > For type "MultiPoint", the "coordinates" member is an array of > positions. [1] https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.4 [2] https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.3
This commit is contained in:
@@ -122,16 +122,6 @@ describe GeojsonFormatValidator do
|
||||
expect(record).not_to be_valid
|
||||
end
|
||||
|
||||
it "is valid with a two-dimensional array including only one point" do
|
||||
record.geojson = '{ "type": "LineString", "coordinates": [[1.23, 4.56]] }'
|
||||
|
||||
expect(record).to be_valid
|
||||
|
||||
record.geojson = '{ "type": "MultiPoint", "coordinates": [[1.23, 4.56]] }'
|
||||
|
||||
expect(record).to be_valid
|
||||
end
|
||||
|
||||
it "is not valid when some coordinates are invalid" do
|
||||
record.geojson = '{ "type": "LineString", "coordinates": [[1.23, 4.56], [180.01, 4.56]] }'
|
||||
|
||||
@@ -153,6 +143,22 @@ describe GeojsonFormatValidator do
|
||||
end
|
||||
end
|
||||
|
||||
context "LineString geometry" do
|
||||
it "is not valid with only one point" do
|
||||
record.geojson = '{ "type": "LineString", "coordinates": [[1.23, 4.56]] }'
|
||||
|
||||
expect(record).not_to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context "MultiPoint geometry" do
|
||||
it "is valid with only one point" do
|
||||
record.geojson = '{ "type": "MultiPoint", "coordinates": [[1.23, 4.56]] }'
|
||||
|
||||
expect(record).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context "GeometryCollection" do
|
||||
it "is not valid if it doesn't contain geometries" do
|
||||
record.geojson = '{ "type": "GeometryCollection" }'
|
||||
|
||||
Reference in New Issue
Block a user