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

New Algorithm - Mesh Surface to Polygon #58941

Merged
merged 29 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
51d144e
new algorithm
JanCaha Oct 2, 2024
6fa1fe8
update feedback
JanCaha Oct 2, 2024
46ae5aa
allow cancel during mesh face processing
JanCaha Oct 2, 2024
2667d2b
allow cancel during mesh faces processing
JanCaha Oct 2, 2024
886d1a0
fix file names
JanCaha Oct 4, 2024
63c7cdf
fix the speed of the algorithm
JanCaha Oct 4, 2024
1843f32
drop not needed imports
JanCaha Oct 4, 2024
62fa703
fix issues
JanCaha Oct 5, 2024
eae1ba0
more readable
JanCaha Oct 5, 2024
5f56704
add mesh layer
JanCaha Oct 23, 2024
fcfccec
test case
JanCaha Oct 23, 2024
6f13887
simplify to avoid warning
JanCaha Oct 23, 2024
639e366
fix issue
JanCaha Oct 23, 2024
f9ab5f9
fix data call
JanCaha Oct 24, 2024
c183c08
fix call
JanCaha Oct 24, 2024
235dfa9
fix expected data
JanCaha Oct 24, 2024
dc25026
handle meshes with holes
JanCaha Nov 27, 2024
23a9c72
add test case
JanCaha Nov 27, 2024
9b357f7
Merge remote-tracking branch 'upstream/master' into mesh-convex-hull
JanCaha Nov 27, 2024
73b0c31
merge from master
JanCaha Dec 5, 2024
0caf6fa
Merge branch 'master' into mesh-convex-hull
JanCaha Dec 5, 2024
370c034
Update src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp
JanCaha Dec 11, 2024
37adda5
Update src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp
JanCaha Dec 11, 2024
3b4ae07
Update src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp
JanCaha Dec 11, 2024
558fa17
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 11, 2024
4c488a7
fix translation
JanCaha Dec 11, 2024
19db67a
typo
JanCaha Dec 11, 2024
50de8a2
clone
JanCaha Dec 11, 2024
7198d78
delete to avoid memory leak
JanCaha Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion python/plugins/processing/tests/AlgorithmsTestBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
QgsCoordinateReferenceSystem,
QgsFeatureRequest,
QgsMapLayer,
QgsMeshLayer,
QgsProject,
QgsApplication,
QgsProcessingContext,
Expand Down Expand Up @@ -267,7 +268,7 @@ def load_param(self, param, id=None):
parameter based on its key `type` and return the appropriate parameter to pass to the algorithm.
"""
try:
if param["type"] in ("vector", "raster", "table"):
if param["type"] in ("vector", "raster", "table", "mesh"):
return self.load_layer(id, param).id()
elif param["type"] == "vrtlayers":
vals = []
Expand Down Expand Up @@ -377,6 +378,8 @@ def load_layer(self, id, param):
options = QgsRasterLayer.LayerOptions()
options.loadDefaultStyle = False
lyr = QgsRasterLayer(filepath, param["name"], "gdal", options)
elif param["type"] == "mesh":
lyr = QgsMeshLayer(filepath, param["name"], "mdal")

self.assertTrue(
lyr.isValid(), f'Could not load layer "{filepath}" from param {param}'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
gml:id="aFeatureCollection"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ mesh_surface_to_polygon.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml/3.2">
<gml:boundedBy><gml:Envelope><gml:lowerCorner>1000 2000</gml:lowerCorner><gml:upperCorner>3000 3000</gml:upperCorner></gml:Envelope></gml:boundedBy>

<ogr:featureMember>
<ogr:mesh_surface_to_polygon gml:id="mesh_surface_to_polygon.0">
<gml:boundedBy><gml:Envelope><gml:lowerCorner>1000 2000</gml:lowerCorner><gml:upperCorner>3000 3000</gml:upperCorner></gml:Envelope></gml:boundedBy>
<ogr:geometryProperty><gml:MultiSurface gml:id="mesh_surface_to_polygon.geom.0"><gml:surfaceMember><gml:Polygon gml:id="mesh_surface_to_polygon.geom.0.0"><gml:exterior><gml:LinearRing><gml:posList>1000 2000 2000 2000 3000 2000 2000 3000 1000 3000 1000 2000</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface></ogr:geometryProperty>
</ogr:mesh_surface_to_polygon>
</ogr:featureMember>
</ogr:FeatureCollection>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="http://ogr.maptools.org/"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:gmlsf="http://www.opengis.net/gmlsf/2.0"
elementFormDefault="qualified"
version="1.0">
<xs:annotation>
<xs:appinfo source="http://schemas.opengis.net/gmlsfProfile/2.0/gmlsfLevels.xsd">
<gmlsf:ComplianceLevel>0</gmlsf:ComplianceLevel>
</xs:appinfo>
</xs:annotation>
<xs:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
<xs:import namespace="http://www.opengis.net/gmlsf/2.0" schemaLocation="http://schemas.opengis.net/gmlsfProfile/2.0/gmlsfLevels.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:AbstractFeature"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="featureMember">
<xs:complexType>
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureMemberType">
<xs:sequence>
<xs:element ref="gml:AbstractFeature"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="mesh_surface_to_polygon" type="ogr:mesh_surface_to_polygon_Type" substitutionGroup="gml:AbstractFeature"/>
<xs:complexType name="mesh_surface_to_polygon_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:MultiSurfacePropertyType" nillable="true" minOccurs="0" maxOccurs="1"/> <!-- restricted to MultiPolygon -->
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
gml:id="aFeatureCollection"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ mesh_surface_to_polygon_complex_mesh_hole.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml/3.2">
<gml:boundedBy><gml:Envelope><gml:lowerCorner>-0.28285357 -10.30319149</gml:lowerCorner><gml:upperCorner>41.54679257 15.32259074</gml:upperCorner></gml:Envelope></gml:boundedBy>

<ogr:featureMember>
<ogr:mesh_surface_to_polygon_complex_mesh_hole gml:id="mesh_surface_to_polygon_complex_mesh_hole.0">
<gml:boundedBy><gml:Envelope><gml:lowerCorner>-0.28285357 -10.30319149</gml:lowerCorner><gml:upperCorner>41.54679257 15.32259074</gml:upperCorner></gml:Envelope></gml:boundedBy>
<ogr:geometryProperty><gml:MultiSurface gml:id="mesh_surface_to_polygon_complex_mesh_hole.geom.0"><gml:surfaceMember><gml:Polygon gml:id="mesh_surface_to_polygon_complex_mesh_hole.geom.0.0"><gml:exterior><gml:LinearRing><gml:posList>-0.28285357 -5.15175219 0 0 0.0 7.5 0 10 5.0 9.5 5.10513141 15.27002503 22.95118899 15.32259074 28.07634543 15.24374218 26.65707134 9.80319149 25.57947434 -1.10419274 21.66332916 -5.91395494 15.80225282 -10.30319149 10.25657071 -10.25062578 -0.28285357 -5.15175219</gml:posList></gml:LinearRing></gml:exterior><gml:interior><gml:LinearRing><gml:posList>10 0 10 10 15.53942428 9.96088861 16.42244099 7.57792771 15.01376721 -0.18429287 10 0</gml:posList></gml:LinearRing></gml:interior></gml:Polygon></gml:surfaceMember><gml:surfaceMember><gml:Polygon gml:id="mesh_surface_to_polygon_complex_mesh_hole.geom.0.1"><gml:exterior><gml:LinearRing><gml:posList>32.85840157 5.894131 37.37097674 6.83705716 41.54679257 12.62931782 34.20543893 11.48433606 32.85840157 5.894131</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface></ogr:geometryProperty>
</ogr:mesh_surface_to_polygon_complex_mesh_hole>
</ogr:featureMember>
</ogr:FeatureCollection>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="http://ogr.maptools.org/"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:gmlsf="http://www.opengis.net/gmlsf/2.0"
elementFormDefault="qualified"
version="1.0">
<xs:annotation>
<xs:appinfo source="http://schemas.opengis.net/gmlsfProfile/2.0/gmlsfLevels.xsd">
<gmlsf:ComplianceLevel>0</gmlsf:ComplianceLevel>
</xs:appinfo>
</xs:annotation>
<xs:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
<xs:import namespace="http://www.opengis.net/gmlsf/2.0" schemaLocation="http://schemas.opengis.net/gmlsfProfile/2.0/gmlsfLevels.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:AbstractFeature"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="featureMember">
<xs:complexType>
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureMemberType">
<xs:sequence>
<xs:element ref="gml:AbstractFeature"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="mesh_surface_to_polygon_complex_mesh_hole" type="ogr:mesh_surface_to_polygon_complex_mesh_hole_Type" substitutionGroup="gml:AbstractFeature"/>
<xs:complexType name="mesh_surface_to_polygon_complex_mesh_hole_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:MultiSurfacePropertyType" nillable="true" minOccurs="0" maxOccurs="1"/> <!-- restricted to MultiPolygon -->
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
MESH2D
ND 1 0 0 0
ND 2 10 0 0
ND 3 10 10 0
ND 4 5 4 0
ND 5 5 2 0
ND 6 0 7.5 0
ND 7 0 10 0
ND 8 5 9.5 0
ND 9 5 6.75 0
ND 10 15.53942428 9.96088861 0
ND 11 15.01376721 -0.18429287 0
ND 12 12.38548185 14.61295369 0
ND 13 22.29411765 9.8557572 0
ND 14 5.10513141 15.27002503 0
ND 15 22.95118899 15.32259074 0
ND 16 10.17772215 -5.23060075 0
ND 17 -0.28285357 -5.15175219 0
ND 18 14.90863579 -5.41458073 0
ND 19 10.25657071 -10.25062578 0
ND 20 15.80225282 -10.30319149 0
ND 21 21.47934919 -1.07790989 0
ND 22 21.66332916 -5.91395494 0
ND 23 26.65707134 9.80319149 0
ND 24 25.57947434 -1.10419274 0
ND 25 28.07634543 15.24374218 0
ND 26 16.42244099 7.57792771 0
ND 27 15.93402616 -0.31148313 0
ND 28 32.85840157 5.894131 0
ND 29 34.20543893 11.48433606 0
ND 30 37.37097674 6.83705716 0
ND 31 41.54679257 12.62931782 0
E3T 1 3 8 2
E3T 2 8 9 2
E3T 3 9 4 2
E3T 4 4 5 2
E3T 5 5 1 2
E3T 6 5 6 1
E3T 7 6 5 7
E3T 8 10 12 3
E3T 9 12 8 3
E3T 10 13 12 10
E3T 11 12 14 8
E3T 12 13 15 12
E3T 13 12 15 14
E3T 14 7 5 4
E3T 15 9 7 4
E3T 16 9 8 7
E3T 17 1 16 2
E3T 18 1 17 16
E4Q 19 16 18 11 2
E3T 20 17 19 16
E4Q 21 19 20 18 16
E3T 22 18 22 21
E3T 23 20 22 18
E3T 24 13 23 15
E3T 25 13 21 23
E3T 26 21 24 23
E3T 27 21 22 24
E3T 28 23 25 15
E3T 29 26 11 13
E3T 30 26 13 10
E3T 31 11 18 27
E3T 32 27 18 21
E3T 33 11 27 13
E3T 34 27 21 13
E3T 35 28 30 29
E3T 36 30 31 29
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,28 @@ tests:
name: expected/create_grid_negative_overlay.gml
type: vector

- algorithm: native:surfacetopolygon
name: Create polygon from surface of Mesh layer
params:
INPUT:
name: quad_and_triangle.2dm
type: mesh
results:
OUTPUT:
name: expected/mesh_surface_to_polygon.gml
type: vector

- algorithm: native:surfacetopolygon
name: Create polygon from surface of Mesh layer - multiple parts with hole
params:
INPUT:
name: mesh_two_part_with_hole.2dm
type: mesh
results:
OUTPUT:
name: expected/mesh_surface_to_polygon_complex_mesh_hole.gml
type: vector

- algorithm: native:rasterminmax
name: Raster min max
params:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MESH2D 1000.000 2000.000 0.000000 200 300 1.000 1.000
ND 1 1000.000 2000.000 20.000
ND 2 2000.000 2000.000 30.000
ND 3 3000.000 2000.000 40.000
ND 4 2000.000 3000.000 50.000
ND 5 1000.000 3000.000 10.000
E4Q 1 1 2 4 5 1
E3T 2 2 3 4 1
1 change: 1 addition & 0 deletions src/analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ set(QGIS_ANALYSIS_SRCS
processing/qgsalgorithmloadlayer.cpp
processing/qgsalgorithmmeancoordinates.cpp
processing/qgsalgorithmmergelines.cpp
processing/qgsalgorithmmeshsurfacetopolygon.cpp
processing/qgsalgorithmmergevector.cpp
processing/qgsalgorithmminimumenclosingcircle.cpp
processing/qgsalgorithmmultidifference.cpp
Expand Down
Loading
Loading