Opened 8 years ago

Closed 5 years ago

#6426 closed defect (wontfix)

Querying a line string for whether it's convex/closed gives inconsistent results

Reported by: dsogari Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: default Version: 2.0.2
Severity: normal Keywords: OGRLineString IsConvex IsClosed
Cc:

Description

I may be mistaken about this, but consider the following piece of code:

OGRLineString *line = new OGRLineString();
line->IsConvex();      // gives true
line->get_IsClosed();  // assertion failure (#1)

line->addPoint(0, 0);
line->IsConvex();      // gives true
line->get_IsClosed();  // gives true

// counter-clockwise one-sided square (not closed)
line->addPoint(1, 0);
line->addPoint(1, 1);
line->addPoint(0, 1);

line->IsConvex();      // gives false (#2)
line->get_IsClosed();  // gives false (ok)

line->addPoint(0, 0);  // close ring
line->IsConvex();      // gives false (#2)
line->get_IsClosed();  // gives true (ok)

line->reversePoints(); // make it clockwise
line->IsConvex();      // gives true (ok)
line->get_IsClosed();  // gives true (ok)
  • Remark 1: why is it that an empty line string cannot be queried for whether it's closed, while it can be queried for whether it's convex?
  • Remark 2: why is it that a line string is convex when its points are laid out clockwisely, whereas it is not convex when they are laid out in counter-clockwise order (either closed or non-closed)?

An example .cpp file is attached for convenience.

Attachments (1)

main.cpp (1.0 KB ) - added by dsogari 8 years ago.
test file

Download all attachments as: .zip

Change History (2)

by dsogari, 8 years ago

Attachment: main.cpp added

test file

comment:1 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.