Skip to content

Fix/invalid polygons#213

Open
marcos-lg wants to merge 3 commits into
devfrom
fix/invalid_polygons
Open

Fix/invalid polygons#213
marcos-lg wants to merge 3 commits into
devfrom
fix/invalid_polygons

Conversation

@marcos-lg

@marcos-lg marcos-lg commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Work for gbif/occurrence#529

I changed some tests because some polygons that were considered invalid they work in the new portal now so I guess we have to accept them. Also there is a test with an old polygon that doesn't pass the WKTReader parsing anymore.

The WithinPredicateTest was outdated because the WithinPredicate constructor doesn't throw an exception anymore so that test was passing but some polygons were actually failing the validation.

@marcos-lg
marcos-lg requested a review from MattBlissett June 24, 2026 16:03
// API no longer throws an exception here.
public void testBadConstructor1() {
new WithinPredicate("POLYGON");
assertNoGeometryWarnings();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be asserting that there is a warning?

It logs one:

14:31:01.797 [main] WARN org.gbif.api.model.predicate.WithinPredicate -- Invalid geometry string POLYGON: Cannot parse simple WKT: POLYGON Expected [(] found EOF

// API no longer throws an exception here.
public void testBadRectangle() {
new WithinPredicate("POLYGON ((30 10, 100 100, 20 40, 40 40, 30 10))");
assertNoGeometryWarnings();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

public void testOldDownload() {
// A polygon that is no longer valid should still be read.
new WithinPredicate("POLYGON((179.99706 50.42798,175.71729 50.32125,164.69551 54.46408,164.41784 58.23259,152.93250 62.42883,149.28338 61.42635,145.49908 63.19071,135.05338 62.47747,121.47856 63.88828,118.42940 61.72106,92.03338 63.48794,88.04893 65.83859,72.38348 64.83205,35.10765 65.27235,20.53798 66.27026,15.93477 63.64430,13.23228 64.16949,14.02329 66.20159,-3.98112 66.35560,-5.28656 60.41050,-24.62696 63.13864,-26.61983 66.37187,-35.26608 65.57732,-42.55152 58.69327,-51.84071 58.60134,-55.81483 49.91863,-85.07522 48.86776,-87.99834 53.35866,-109.22832 59.11742,-121.84178 55.37470,-134.08814 63.56701,-141.82291 64.54874,-141.93138 68.24804,-158.60607 65.39087,-150.05958 56.55879,-167.23505 51.12098,-180.00299 50.42801,-180.00000 90.00000,180.00000 90.00000,179.99706 50.42798))");
assertNoGeometryWarnings();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here, if the test is enabled again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants