Skip to content

Conversation

@hefniraera
Copy link
Collaborator

Refs #9530

Goal:

Ticket(s): #

  • Backport to LTR documentation is requested

@DelazJ DelazJ added the backport release_3.44 On merge create a backported pull request to 3.44 label Oct 7, 2025
@hefniraera hefniraera force-pushed the geometry-checker-polyexceeds branch from ad3e5bf to 2990609 Compare October 8, 2025 02:02
Polygons exceeding boundaries
-----------------------------

Checks if the polygons follow the boundaries of the reference layer.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This sentence looks obscure to me. We really should clarify what "follows boundaries" means. To what extent a feature is considered as following (or not) another one's boundary? Too unclear to me to suggest any rewording.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well the alg name itself a bit misleading qgis/QGIS#63454 (comment)
I think the idea is that polygon boundary should lie completely on the reference. If it exceeds, errors will be detected. Regarding what extent, I tried to stretch them, made it distant from the reference, and no error detected.
image

But if you make it like this, close to the reference layer, it will be considered as error.
image

Copy link
Collaborator Author

@hefniraera hefniraera Oct 16, 2025

Choose a reason for hiding this comment

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

Hashed is the reference layer, yellow one is the input. This also won't be detected as error, as long as we have the input parts are completely within the hashed regardless the geometries aren't identical.

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

But if you make it like this, close to the reference layer, it will be considered as error.

The key point is "how close should they be?". And I'm not sure it has anything to do with that 10^-8 tolerance value.

If it exceeds, errors will be detected

I'm not sure either. See below (hashed are check features). They snap to the reference feature vertices except one vertex. And both are errors.
image
Well, at some point I don't think we have to try to guess what is in play. It is up to devs to provide necessary information for a reliable documentation. @Djedouas we will really need your help to clarify what "follow boundaries" actually means (and we also have questions in #10326). Thanks.


- ``gc_layerid``: the ID of the input layer.
- ``gc_layername``: the name of the input layer.
- ``gc_partidx``
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still, no output for these fields?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes still

- ``POLYGONS``
- [vector: polygon]
- Layer with the polygons to check against.
* - **Errors exceeding boundaries**
Copy link
Collaborator

Choose a reason for hiding this comment

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

This label is not obvious...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's try to use simpler geometric shapes for features

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any feedback would be appreciated
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

With this example; it is hard to understand what triggers the error: the offset at the left, the middle or the right? An error feature should be caused by a single reason, easier for users to understand.

@DelazJ DelazJ added the Processing Alg (Features of) An algorithm. Use the Help button in the application to find the page. label Oct 20, 2025
@hefniraera hefniraera force-pushed the geometry-checker-polyexceeds branch from 2990609 to d29ada2 Compare October 21, 2025 02:26
@Djedouas
Copy link
Member

Hi,

This algorithm is not easy to explain...

It checks if features are following boundaries of reference features found in the reference layer.

Algorithm

This is how it works: for each feature in the layer to test

  • if no feature bounding box of the reference layer is intersecting the feature bounding box to test, then the feature to test is not following any boundary -> error
  • all features from the reference layer that have their bounding box intersecting the feature to test bounding box must be either contained or disjoint from the feature to test, else -> error

The error is marked on the feature itself, not where the error is really located. It is the feature that is considered an error. Thus, the location point is on the feature centroïd.

I don't really know what a user case could be for this, but I guess that it relates to verifying that borders are correctly following each other.

Here are the layers that are used for the unit tests in QGIS:

image

Red is the reference layer, green is the layer to test.

They are in tests/testdata/geometry_checker/follow_ref.shp and follow_subj.shp

Zoom 1

image

We will have an error here.

There are 2 reference features, the one under the test feature and the one around.

The one around is disjoint with the test feature, this is ok.

The one under is not contained and not disjoint, this is an error.

Zoom 2

image

We will have no error here.

There are 2 reference features, the one under the test feature and the one around.

The one around is disjoint with the test feature, this is ok.

The one under is contained, this is ok.

If we have only one reference feature

(Added hatching and lowered opacity to see the overlapping features).
image

Nb. 1. the reference feature is not contained inside the test feature, and they are not disjoint. It does not follow boundaries. There is an error.

Nb. 2. the reference feature is contained inside the test feature, there is no error. This is somehow strange from a use case point of view because one could say that the test feature does not follow boundaries.

Nb. 3. the two features are the same: the reference feature is contained inside the test feature. No error.

Nb. 4. there is a hole in the reference feature, and the test feature follows the hole boundaries. The features are disjoint. No error.

Nb. 5. the test feature does not follow the hole boundaries. But the reference feature is not contained in the test feature, and they are disjoint. No error. Quite strange from a use case point of view as well, because one could say that the test feature does not follow boundaries.

Nb. 6. the test feature does not follow the hole boundaries. The reference feature and the test feature are not disjoint. There is an error.

Discussion

In fact, the QGIS unit test verifies that the test features are strictly following boundaries of reference features. I guess that this is the closer to the use case.

They can't exceed the boundary because this would be an error with the reference feature that is around the test feature, and they can't be smaller because this would be an error with the reference feature under them.

But the previous examples show some strange results based on my guess of use case. I don't know if this is correct or not, and this is quite complicated to explain in a documentation. I can only state what the geometry checker checks here, because I worked on migrating this to the processing framework, and not on the original algorithm.

@hefniraera
Copy link
Collaborator Author

Thanks @Djedouas for the clarification. This is very helpful. Well, I think we don't necessarily need to add screenshot here? A lot of things are going on here, I'm not sure we can get one point of what follow boundaries actually means. Ideas? @DelazJ

@DelazJ
Copy link
Collaborator

DelazJ commented Oct 24, 2025

Trying to reformulate the rules (after I took some headache medicine), in a way to highlight behavior of the correct input feature

  • if no feature bounding box of the reference layer is intersecting the feature bounding box to test, then the feature to test is not following any boundary -> error

---> if the input feature bounding box does not intersect a reference feature bounding box, then the input feature is not following any boundary -> error (logic, they are potentially "too far" from each other)

  • all features from the reference layer that have their bounding box intersecting the feature to test bounding box must be either contained or disjoint from the feature to test, else -> error

--> If the input feature bounding box intersects reference features bounding boxes, for each of the reference features, the input feature should either contain them or not share any portion of area with them .

Summary: An input feature follows boundaries if:

  • its bbox intersects at least one reference feature's bbox AND
  • its geometry contains those reference features geometry or does not overlap them.

Sorry to say, but this looks messy!!! I'm failing to see what real world scenario this tries to cover, and I confirm that the alg behaves the same as the geometry checker plugin. I fail to see when we are following any boundary in the above scenarios, and suspect a broken feature.
Is this a feature we want to keep in QGIS (at least in its current shape) ?

@Djedouas
Copy link
Member

Summary: An input feature follows boundaries if:

  • its bbox intersects at least one reference feature's bbox AND
  • its geometry contains those reference features geometry or does not overlap them.

Yes

Sorry to say, but this looks messy!!! I'm failing to see what real world scenario this tries to cover, and I confirm that the alg behaves the same as the geometry checker plugin. I fail to see when we are following any boundary in the above scenarios, and suspect a broken feature.

Me too

Is this a feature we want to keep in QGIS (at least in its current shape) ?

Who could answer this?

@DelazJ
Copy link
Collaborator

DelazJ commented Oct 28, 2025

I would say developers ! Let's see https://www.mail-archive.com/[email protected]/msg57084.html.

@hefniraera
Copy link
Collaborator Author

Can we close this? @DelazJ

@DelazJ
Copy link
Collaborator

DelazJ commented Dec 15, 2025

@hefniraera I'd have said yes.
@Djedouas Sorry I just notice you replied after my follow-up. I personally had given up and was leaning toward suggesting to remove the alg and the option. Do you think anything would come of asking users?
that said, nothing prevents us from closing this if we want to clear the issues queue in the meantime.

@DelazJ
Copy link
Collaborator

DelazJ commented Dec 15, 2025

Sorry I just notice you replied after my follow-up.

Actually, it was sent today... I thought it was for a long time ago. _ I should go and sleep._

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

Labels

backport release_3.44 On merge create a backported pull request to 3.44 Processing Alg (Features of) An algorithm. Use the Help button in the application to find the page.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants