Skip to content

Commit

Permalink
support case of LineStrings with only 1 coordinate pair
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Nov 4, 2024
1 parent 2b3949d commit 16b65ce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/s2geography/geoarrow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,15 @@ class WriterImpl {

int VisitPolylineEdges(const S2Polyline& poly) {

if (poly.num_vertices() == 0) {
throw Exception("Unexpected S2Polyline with 0 vertices");
} else if (poly.num_vertices() == 1) {
// this is an invalid case, but we handle it for printing
ProjectS2Point(poly.vertex(0));
GEOARROW_RETURN_NOT_OK(visitor_.coords(&visitor_, &coords_view_));
return GEOARROW_OK;
}

for (int i = 1; i < poly.num_vertices(); i++) {
const S2Point& pt0(poly.vertex(i - 1));
const S2Point& pt1(poly.vertex(i));
Expand Down

0 comments on commit 16b65ce

Please sign in to comment.