forked from cnheider/jord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
148 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ | |
from .actions import * | ||
from .groups import * | ||
from .logging import * | ||
from .randomize import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import uuid | ||
|
||
__all__ = ["randomize_field", "randomize_sub_tree_field"] | ||
|
||
|
||
def randomize_sub_tree_field(selected_nodes, field_name: str) -> None: | ||
# noinspection PyUnresolvedReferences | ||
from qgis.core import QgsLayerTreeGroup, QgsLayerTreeLayer | ||
|
||
for group in selected_nodes: | ||
if isinstance(group, QgsLayerTreeLayer): | ||
randomize_field(group, field_name=field_name) | ||
elif isinstance(group, QgsLayerTreeGroup): | ||
randomize_sub_tree_field(group.children(), field_name=field_name) | ||
else: | ||
... | ||
|
||
|
||
def randomize_field(tree_layer, field_name: str) -> None: #: QgsLayerTreeLayer | ||
""" | ||
https://qgis.org/pyqgis/3.28/core/QgsVectorLayer.html#qgis.core.QgsVectorLayer.changeAttributeValues | ||
changeAttributeValues | ||
fid: int, newValues: Dict[int, Any], oldValues: Dict[int, Any] = {}, skipDefaultValues: bool = False | ||
:param field_name: | ||
:param tree_layer: | ||
:return: | ||
""" | ||
layer = tree_layer.layer() | ||
|
||
field_idx = layer.fields().indexFromName(field_name) | ||
|
||
if field_idx >= 0: | ||
layer.startEditing() | ||
layer.beginEditCommand(f"Regenerate {field_name}") | ||
for i in range(layer.featureCount() + 1): | ||
layer.changeAttributeValue(i, field_idx, uuid.uuid4().hex) | ||
|
||
# layer.rollBack() | ||
layer.endEditCommand() | ||
layer.commitChanges() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
] | ||
|
||
try: | ||
|
||
from PyQt6.QtCore import Qt | ||
|
||
class AlignmentFlag(Flag): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
apppath>=1.0.2 | ||
draugr>=1.0.9 | ||
numpy>=1.20.0 | ||
pyzmq | ||
sorcery | ||
sympy | ||
tqdm | ||
pyzmq>=1.1.1 | ||
sorcery>=0.2.0 | ||
sympy>=1.1.1 | ||
tqdm>=1.1.1 | ||
warg>=1.1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
fiona | ||
fiona>=1.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pyqt5-tools | ||
PySide2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
import shapely | ||
|
||
from jord.shapely_utilities import dilate, erode, opening, closing | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"shape", | ||
( | ||
shapely.Point(0, 0), | ||
shapely.LinearRing([(-1, -1), (1, 1), (1, 1), (1, -1), (-1, -1)]), | ||
shapely.LineString([(-1, -1), (1, 1), (1, 1), (1, -1), (-1, -1)]), | ||
shapely.Polygon( | ||
shapely.LinearRing([(-1, -1), (1, 1), (1, 1), (1, -1), (-1, -1)]) | ||
), | ||
shapely.MultiPolygon( | ||
[ | ||
shapely.Polygon( | ||
shapely.LinearRing([(-1, -1), (1, 1), (1, 1), (1, -1), (-1, -1)]) | ||
) | ||
] | ||
), | ||
shapely.MultiPoint([shapely.Point(0, 0)]), | ||
shapely.MultiLineString( | ||
[shapely.LineString([(-1, -1), (1, 1), (1, 1), (1, -1), (-1, -1)])] | ||
), | ||
shapely.GeometryCollection( | ||
[ | ||
shapely.Point(0, 0), | ||
shapely.LineString([(-1, -1), (1, 1), (1, 1), (1, -1), (-1, -1)]), | ||
] | ||
), | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
"operation", | ||
((dilate, erode, closing, opening)), | ||
) | ||
def test_operation_zero(operation, shape): | ||
shape.equals(operation(shape, distance=0)) |