Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Points Along Geometry" not creating points if geometry is multipart #34022

Closed
earthcli opened this issue Jan 25, 2020 · 10 comments · Fixed by #34140
Closed

"Points Along Geometry" not creating points if geometry is multipart #34022

earthcli opened this issue Jan 25, 2020 · 10 comments · Fixed by #34140
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms

Comments

@earthcli
Copy link

I found the result of qgis:pointsalonglines with v3.10 and 3.2.2 are different, exactly the new version gives a wrong result. see the screenshot attatched.

Uploading floodchain with QGIS3.10 version.png…

@earthcli earthcli added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jan 25, 2020
@earthcli
Copy link
Author

flood chain with  QGIS3 2 2 version

@earthcli
Copy link
Author

floodchain with QGIS3 10 version

@gioman gioman changed the title wrong result from qgis:pointsalonglines with v3.10 wrong result from Points Along Lines with QGIS 3.10 Jan 25, 2020
@gioman
Copy link
Contributor

gioman commented Jan 25, 2020

@earthcli can you attach sample data?

@gioman gioman added the Processing Relating to QGIS Processing framework or individual Processing algorithms label Jan 25, 2020
@earthcli
Copy link
Author

@gioman Thanks for your quick response, the sample data is located here:
https://github.com/pcoddo/CambodiaFloods/tree/master/1_Depth_Estimation/Layers

the input is the 'flood_lines.shp'

@gioman gioman changed the title wrong result from Points Along Lines with QGIS 3.10 "Points Along Geometry" not creating points if geometry is multipart Jan 25, 2020
@gioman
Copy link
Contributor

gioman commented Jan 25, 2020

the input is the 'flood_lines.shp'

the lines where the point are not created are multi-part geometries, if you first use "multipart to singleparts" the result is the expected one, but apparently is still a regression anyway.

@earthcli
Copy link
Author

I see, many thanks.

@agiudiceandrea
Copy link
Contributor

@earthcli, with QGIS 3.10 are you using gdal:pointsalonglines or native:pointsalonglines?

qgis:pointsalonglines is no longer in QGIS 3.10.

If you are using native:pointsalonglines while in QGIS 3.2 you used qgis:pointsalonglines, the problem could be related to the algorithm port to c++ #30175.

@earthcli
Copy link
Author

@agiudiceandrea I use qgis:pointsalonglines in the plugin python console, it does works,
I have also tried run it with the processing box GUI (module: points along geometry) , I get the identical result as in python console.

@agiudiceandrea
Copy link
Contributor

In QGIS 3.10.1 (on my Windows 7 system) hovering the pointer on the algorithm name "Points along geometry" in the processing toolbox I see "Algorithm ID: 'native:pointsalonglines'".

In the python console, executing QgsApplication.processingRegistry().algorithmById("qgis:pointsalonglines").id() I see "'native:pointsalonglines'".
So, in QGIS 3.10, qgis:pointsalonglines (the name of the old python algorithm) is only an alias for native:pointsalonglines (the new c++ algorithm).

@nyalldawson nyalldawson self-assigned this Jan 28, 2020
@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jan 28, 2020

Both QGIS 3.4.5 (which uses the python version of the algorithm) and QGIS 3.10.1 (which uses the c++ version) seem to behave the same way when a multi part geometry feature is processed by "Points along geometry" alg:

  1. points are generated only on the basis of the first part of a multi-part (line/polygn) geometry

This seems more likely related to a change in QgsGeometry::interpolate (c6a91da #7587) on which both the algorithm versions rely on.
Since 3.4, QgsGeometry::interpolate works only on the first part of a multi-part geometry by design.

// if multi part, just use first part
Before 3.4 (i.e. 3.2.2), it relies on GEOS in order to interpolate.

  1. additional spurious points with null coordinates are generated

This seems related to the algorithm itself (both python and c++ versions) that doesn't take into account the aforementioned change and doesn't test for multi part geometry, so it tries to generate the points along the total length/perimeter of a multi part line/polygon geometry instead of along the length/perimeter of the first part only.

const double totalLength = geometry.type() == QgsWkbTypes::PolygonGeometry ? geometry.constGet()->perimeter()
: geometry.length() - endOffset;

if input_geometry.type == QgsWkbTypes.PolygonGeometry:
length = input_geometry.constGet().perimeter()
else:
length = input_geometry.length() - end_offset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants