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.
start support serialisation, not done
- Loading branch information
Showing
4 changed files
with
211 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
from typing import Any | ||
|
||
APPEND_TIMESTAMP = True | ||
SKIP_MEMORY_LAYER_CHECK_AT_CLOSE = True | ||
PIXEL_SIZE = 1 | ||
DEFAULT_NUMBER = 0 | ||
CONTRAST_ENHANCE = True | ||
DEFAULT_LAYER_NAME = "TemporaryLayer" | ||
DEFAULT_LAYER_CRS = "EPSG:4326" | ||
VERBOSE = False | ||
|
||
__all__ = [ | ||
"serialise_qgis_layer", | ||
] | ||
|
||
|
||
def serialise_qgis_layer(qgis_instance_handle: Any, layer: Any) -> None: | ||
""" | ||
https://qgis.org/pyqgis/3.28/core/QgsJsonUtils.html#qgis.core.QgsJsonUtils.exportAttributes | ||
https://qgis.org/pyqgis/3.28/core/QgsJsonExporter.html | ||
asGeometryCollection | ||
Returns contents of the geometry as a list of geometries | ||
asJson | ||
Exports the geometry to a GeoJSON string. | ||
asMultiPoint | ||
Returns the contents of the geometry as a multi-point. | ||
asMultiPolygon | ||
Returns the contents of the geometry as a multi-polygon. | ||
asMultiPolyline | ||
Returns the contents of the geometry as a multi-linestring. | ||
asPoint | ||
Returns the contents of the geometry as a 2-dimensional point. | ||
asPolygon | ||
Returns the contents of the geometry as a polygon. | ||
asPolyline | ||
Returns the contents of the geometry as a polyline. | ||
asQPointF | ||
Returns contents of the geometry as a QPointF if wkbType is WKBPoint, otherwise returns a null QPointF. | ||
asQPolygonF | ||
Returns contents of the geometry as a QPolygonF. | ||
asWkb | ||
Export the geometry to WKB | ||
asWkt | ||
Exports the geometry to WKT | ||
TODO: Figure this | ||
:param qgis_instance_handle: | ||
:param layer: | ||
:return: | ||
""" | ||
|
||
# noinspection PyUnresolvedReferences | ||
from qgis.core import QgsVectorLayer, QgsFeature, QgsJsonExporter | ||
|
||
# noinspection PyUnresolvedReferences | ||
import qgis | ||
|
||
assert isinstance(layer, QgsVectorLayer) | ||
|
||
# geom_geojson_rep = layer.asJson(precision=17) | ||
layer_geojson_rep = QgsJsonExporter( | ||
layer, precision=17 | ||
) # Note that geometries will be automatically reprojected to WGS84 to match GeoJSON spec if either the source vector layer or source CRS is set. |
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