# segment-reshape-qgis-plugin
QGIS plugin with a map tool to reshape a continuous segment topogically.
## Plugin
`Segment reshape tool` plugin is available from the QGIS plugin repository. It provides a simple toolbar with one action. Action will activate a segment reshape map tool, with which a common segment portion can be clicked and a new segment can be digitized. After digitizing the features are edited to match the new common segment.
## Library
To use this library as an external dependency in your plugin or other Python code, install it using `pip install segment-reshape-qgis-plugin` and use imports from the provided `segment_reshape` package. If used in a plugin, library must be installed in the runtime QGIS environment or use [qgis-plugin-dev-tools] to bundle your plugin with runtime dependencies included.
### API documentation
Simple use case can be seen in [integration test](./test/integration/test_simple_line_reshape.py).
#### Finding common segment
`segment_reshape.topology.find_related.find_segment_to_reshape` calculates the line segment between features that share equal sequence of vertices along their edges at the trigger location. By default all QGIS project layers are used to find connected features if topological editing is enabled. Custom list of layers can also be passed as an argument.
Return values are:
- Common segment (`None` if not found)
- Features that share the common segment (and relevant vertex indices)
- Features that share the end points of the common segment (and relevant vertex index)
#### Editing geometries partially
`segment_reshape.geometry.reshape.make_reshape_edits` reshapes the provided common parts and edges, so that common part shared vertex indices are replaced and edges are moved to match the reshaped geometry. Output of `find_segment_to_reshape` (common parts & edges) can be used as input for this function.
#### Map tool
Map tool is found in `segment_reshape.map_tool.segment_reshape_tool.SegmentReshapeTool`, it can be subclassed or used as is in custom plugins.
The Map Tool should be taken into use as follows:
```python
from segment_reshape.map_tool.segment_reshape_tool import (
SegmentReshapeTool,
SegmentReshapeToolHandler,
)
class SegmentReshapePlugin(QObject):
def __init__(self, iface) -> None:
super().__init__(parent=None)
self.iface = iface
self.segment_reshape_tool = SegmentReshapeTool(iface.mapCanvas())
def initGui(self) -> None:
self.segment_reshape_tool_action = QAction(
QIcon(resources_path("icons/segment_reshape.svg")),
self.tr("Reshape common segment"),
self.iface.mainWindow(),
)
self.segment_reshape_tool_handler = SegmentReshapeToolHandler(
self.segment_reshape_tool, self.segment_reshape_tool_action
)
self.iface.registerMapToolHandler(self.segment_reshape_tool_handler)
self.toolbar = iface.addToolBar(
self.tr("Segment reshape toolbar"),
)
self.toolbar.addAction(self.segment_reshape_tool_action)
```
## Development of segment-reshape-qgis-plugin
See [development readme](./DEVELOPMENT.md).
## License & copyright
Licensed under GNU GPL v3.0.
Copyright (C) 2022 [National Land Survey of Finland].
[National Land Survey of Finland]: https://www.maanmittauslaitos.fi/en
[qgis-plugin-dev-tools]: https://github.com/nlsfi/qgis-plugin-dev-tools
# CHANGELOG
## [0.1.6] - 2023-09-06
- update author email
## [0.1.5] - 2023-08-16
- Fix: Add support for reshaping closed linestrings
- Fix: Add support for reshaping closed linestring partially, when the reshaped segment falls on the wraparound location
## [0.1.4] - 2023-04-14
- Feature: Change the mouse cursor to the wait cursor when finding common segment os editing is in progress
- Performance improvments. Finding a common segment should now be a magnitude faster with large geometries.
## [0.1.3] - 2023-03-23
- Feature: Digitizing the new geometry for a segment behaves now as the native QGIS digitizing tools. It supports etc. snapping, tracing and advanced cad tools.
- Feature: Map tool button is enabled only when a line or polygon layer is active. This is implemented through MapToolHandler which ensures that the tool behaves like rest of the map tools. This means also that the tool can be deactivated only by selecting another map tool.
- Fix: Color of the start point indicator line was changed to grey to make difference to the digitized line.
## [0.1.2] - 2023-02-23
- Feature: Set z coordinate values of the reshaped geometry to QGIS's default z coordinate value instead of NaN
## [0.1.1] - 2023-01-17
- Fix: Correcly move multiple edges for same feature.
## [0.1.0] - 2022-12-14
- Feature: Add support for key commands (backspace and esc) in vertex editing.
- Fix: In cases where segment was split from the middle the start and end parts of the line is correctly merged back together.
- Fix: Geometry comparison was fixed so that only common vertices between geometries are taken into account. Before edges were split if an edge crossed other edge also from non vertex point.
- Feature: Preserve source feature z coordinate for calculated segment.
## [0.0.3] - 2022-11-17
- Fix: Fix missing toolbar icon by including resource files in setuptools build.
## [0.0.2] - 2022-11-09
- Feature: Implement a QGIS plugin with a simple toolbar.
- Feature: Add map tool for selecting and drawing the reshape geometry.
- Feature: Support complex calculation for the common segment.
- Feature: Add snapping support when drawing the reshape geometry.
## [0.0.1] - 2022-10-28
- Initial release: API for finding common segments and making reshape edits.
[0.0.1]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.0.1
[0.0.2]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.0.2
[0.0.3]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.0.3
[0.1.0]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.0
[0.1.1]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.1
[0.1.2]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.2
[0.1.3]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.3
[0.1.4]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.4
[0.1.5]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.5
[0.1.6]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.6
Raw data
{
"_id": null,
"home_page": "https://github.com/nlsfi/segment-reshape-qgis-plugin",
"name": "segment-reshape-qgis-plugin",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "qgis",
"author": "National Land Survey of Finland",
"author_email": "os@nls.fi",
"download_url": "https://files.pythonhosted.org/packages/05/08/ad109751b4ea93af55d4ef26acd16effd150625148c05eff461450d2436e/segment-reshape-qgis-plugin-0.1.6.tar.gz",
"platform": null,
"description": "# segment-reshape-qgis-plugin\n\nQGIS plugin with a map tool to reshape a continuous segment topogically.\n\n## Plugin\n\n`Segment reshape tool` plugin is available from the QGIS plugin repository. It provides a simple toolbar with one action. Action will activate a segment reshape map tool, with which a common segment portion can be clicked and a new segment can be digitized. After digitizing the features are edited to match the new common segment.\n\n## Library\n\nTo use this library as an external dependency in your plugin or other Python code, install it using `pip install segment-reshape-qgis-plugin` and use imports from the provided `segment_reshape` package. If used in a plugin, library must be installed in the runtime QGIS environment or use [qgis-plugin-dev-tools] to bundle your plugin with runtime dependencies included.\n\n### API documentation\n\nSimple use case can be seen in [integration test](./test/integration/test_simple_line_reshape.py).\n\n#### Finding common segment\n\n`segment_reshape.topology.find_related.find_segment_to_reshape` calculates the line segment between features that share equal sequence of vertices along their edges at the trigger location. By default all QGIS project layers are used to find connected features if topological editing is enabled. Custom list of layers can also be passed as an argument.\n\nReturn values are:\n\n- Common segment (`None` if not found)\n- Features that share the common segment (and relevant vertex indices)\n- Features that share the end points of the common segment (and relevant vertex index)\n\n#### Editing geometries partially\n\n`segment_reshape.geometry.reshape.make_reshape_edits` reshapes the provided common parts and edges, so that common part shared vertex indices are replaced and edges are moved to match the reshaped geometry. Output of `find_segment_to_reshape` (common parts & edges) can be used as input for this function.\n\n#### Map tool\n\nMap tool is found in `segment_reshape.map_tool.segment_reshape_tool.SegmentReshapeTool`, it can be subclassed or used as is in custom plugins.\n\nThe Map Tool should be taken into use as follows:\n\n```python\n\nfrom segment_reshape.map_tool.segment_reshape_tool import (\n SegmentReshapeTool,\n SegmentReshapeToolHandler,\n)\n\nclass SegmentReshapePlugin(QObject):\n def __init__(self, iface) -> None:\n super().__init__(parent=None)\n self.iface = iface\n\n self.segment_reshape_tool = SegmentReshapeTool(iface.mapCanvas())\n\n def initGui(self) -> None:\n self.segment_reshape_tool_action = QAction(\n QIcon(resources_path(\"icons/segment_reshape.svg\")),\n self.tr(\"Reshape common segment\"),\n self.iface.mainWindow(),\n )\n self.segment_reshape_tool_handler = SegmentReshapeToolHandler(\n self.segment_reshape_tool, self.segment_reshape_tool_action\n )\n self.iface.registerMapToolHandler(self.segment_reshape_tool_handler)\n\n self.toolbar = iface.addToolBar(\n self.tr(\"Segment reshape toolbar\"),\n )\n self.toolbar.addAction(self.segment_reshape_tool_action)\n\n```\n\n## Development of segment-reshape-qgis-plugin\n\nSee [development readme](./DEVELOPMENT.md).\n\n## License & copyright\n\nLicensed under GNU GPL v3.0.\n\nCopyright (C) 2022 [National Land Survey of Finland].\n\n[National Land Survey of Finland]: https://www.maanmittauslaitos.fi/en\n[qgis-plugin-dev-tools]: https://github.com/nlsfi/qgis-plugin-dev-tools\n\n# CHANGELOG\n\n## [0.1.6] - 2023-09-06\n\n- update author email\n\n## [0.1.5] - 2023-08-16\n\n- Fix: Add support for reshaping closed linestrings\n- Fix: Add support for reshaping closed linestring partially, when the reshaped segment falls on the wraparound location\n\n## [0.1.4] - 2023-04-14\n\n- Feature: Change the mouse cursor to the wait cursor when finding common segment os editing is in progress\n- Performance improvments. Finding a common segment should now be a magnitude faster with large geometries.\n\n## [0.1.3] - 2023-03-23\n\n- Feature: Digitizing the new geometry for a segment behaves now as the native QGIS digitizing tools. It supports etc. snapping, tracing and advanced cad tools.\n- Feature: Map tool button is enabled only when a line or polygon layer is active. This is implemented through MapToolHandler which ensures that the tool behaves like rest of the map tools. This means also that the tool can be deactivated only by selecting another map tool.\n- Fix: Color of the start point indicator line was changed to grey to make difference to the digitized line.\n\n## [0.1.2] - 2023-02-23\n\n- Feature: Set z coordinate values of the reshaped geometry to QGIS's default z coordinate value instead of NaN\n\n## [0.1.1] - 2023-01-17\n\n- Fix: Correcly move multiple edges for same feature.\n\n## [0.1.0] - 2022-12-14\n\n- Feature: Add support for key commands (backspace and esc) in vertex editing.\n- Fix: In cases where segment was split from the middle the start and end parts of the line is correctly merged back together.\n- Fix: Geometry comparison was fixed so that only common vertices between geometries are taken into account. Before edges were split if an edge crossed other edge also from non vertex point.\n- Feature: Preserve source feature z coordinate for calculated segment.\n\n## [0.0.3] - 2022-11-17\n\n- Fix: Fix missing toolbar icon by including resource files in setuptools build.\n\n## [0.0.2] - 2022-11-09\n\n- Feature: Implement a QGIS plugin with a simple toolbar.\n- Feature: Add map tool for selecting and drawing the reshape geometry.\n- Feature: Support complex calculation for the common segment.\n- Feature: Add snapping support when drawing the reshape geometry.\n\n## [0.0.1] - 2022-10-28\n\n- Initial release: API for finding common segments and making reshape edits.\n\n[0.0.1]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.0.1\n[0.0.2]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.0.2\n[0.0.3]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.0.3\n[0.1.0]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.0\n[0.1.1]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.1\n[0.1.2]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.2\n[0.1.3]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.3\n[0.1.4]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.4\n[0.1.5]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.5\n[0.1.6]: https://github.com/nlsfi/segment-reshape-qgis-plugin/releases/tag/v0.1.6\n",
"bugtrack_url": null,
"license": "GNU GPL v3.0",
"summary": "QGIS plugin with a map tool to reshape a continuous segment topogically.",
"version": "0.1.6",
"project_urls": {
"Changelog": "https://github.com/nlsfi/segment-reshape-qgis-plugin/blob/main/CHANGELOG.md",
"Homepage": "https://github.com/nlsfi/segment-reshape-qgis-plugin"
},
"split_keywords": [
"qgis"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "19868ea7104d3ab474c307d256f03e980b84fdd4fc946a77d2d9cceb6886b258",
"md5": "04141271f0aabf31eccd6a87e3752e0a",
"sha256": "6a19bf466ad4a69602971aa4a4de67e8de1cccffb1eac868ed45ea716dc32fbe"
},
"downloads": -1,
"filename": "segment_reshape_qgis_plugin-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "04141271f0aabf31eccd6a87e3752e0a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 37841,
"upload_time": "2023-09-06T10:27:22",
"upload_time_iso_8601": "2023-09-06T10:27:22.837222Z",
"url": "https://files.pythonhosted.org/packages/19/86/8ea7104d3ab474c307d256f03e980b84fdd4fc946a77d2d9cceb6886b258/segment_reshape_qgis_plugin-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0508ad109751b4ea93af55d4ef26acd16effd150625148c05eff461450d2436e",
"md5": "46e6a42adefdfa4bbd9aad3f3e187512",
"sha256": "d4122a74a22640f8e0718bda3aa360458457bae1b0c2932151c8859ccee78d59"
},
"downloads": -1,
"filename": "segment-reshape-qgis-plugin-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "46e6a42adefdfa4bbd9aad3f3e187512",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 33013,
"upload_time": "2023-09-06T10:27:24",
"upload_time_iso_8601": "2023-09-06T10:27:24.627787Z",
"url": "https://files.pythonhosted.org/packages/05/08/ad109751b4ea93af55d4ef26acd16effd150625148c05eff461450d2436e/segment-reshape-qgis-plugin-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-06 10:27:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nlsfi",
"github_project": "segment-reshape-qgis-plugin",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "segment-reshape-qgis-plugin"
}