Skip to content

Commit

Permalink
updating rsxml to 2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
MattReimer committed Aug 8, 2024
1 parent e2e58d2 commit 8ab7d95
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 14 deletions.
3 changes: 2 additions & 1 deletion python/packages/rsxml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ You can construct an instance of a `Project` class that incorporates all the nec
meta_data=MetaData(values=[Meta('Test', 'Test Value')]),
layers=[
GeopackageLayer(
lyr_name='layer1',
lyr_name='my_layer1',
name='Layer1',
ds_type=GeoPackageDatasetTypes.VECTOR,
summary='This is a dataset',
description='This is a dataset',
citation='This is a citation',
meta_data=MetaData(values=[Meta('Test', 'Test Value')])
lyr_type='my_layer',
)
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
- https://qgis.org/pyqgis/3.2/core/Message/QgsMessageLog.html
"""
import logging
from rsxml import Logger
import tempfile

Expand Down
30 changes: 28 additions & 2 deletions python/packages/rsxml/examples/project_01_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
Coords,
BoundingBox,
Dataset,
Geopackage,
GeopackageLayer,
GeoPackageDatasetTypes,
Realization,
)
Expand Down Expand Up @@ -79,7 +81,31 @@ def main(filepath: str):
ds_type=GeoPackageDatasetTypes.RASTER,
summary='This is a input dataset',
description='This is a input dataset',
)
),
Geopackage(
xml_id='output2',
name='OutputDS2',
path='datasets/output.gpkg',
layers=[
GeopackageLayer(
lyr_name='output2_layer1',
lyr_type='output_layer',
name='OutputDS2 Layer 1',
ds_type=GeoPackageDatasetTypes.VECTOR,
summary='This is a input dataset',
description='This is a input dataset',
),
GeopackageLayer(
lyr_name='output2_layer2',
name='OutputDS2 Layer 2',
ds_type=GeoPackageDatasetTypes.VECTOR,
summary='This is a input dataset',
description='This is a input dataset',
),
],
summary='This is a input dataset',
description='This is a input dataset',
),
]
)
]
Expand Down Expand Up @@ -158,4 +184,4 @@ def main(filepath: str):
# </Outputs>
# </Realization>
# </Realizations>
# </Project>
# </Project>
5 changes: 1 addition & 4 deletions python/packages/rsxml/rsxml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
"""_summary_
"""

from rsxml.dotenv import *
from rsxml.util import *
from rsxml.rspaths import *
from rsxml.validation import *
from rsxml.validation import fetch_xml, validate_xml, validate_project_file
from rsxml.etag import calculate_etag

# Logging tools
Expand Down
2 changes: 1 addition & 1 deletion python/packages/rsxml/rsxml/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.5"
__version__ = "2.0.6"
12 changes: 10 additions & 2 deletions python/packages/rsxml/rsxml/project_xml/Geopackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class GeopackageLayer(RSObj):
"""
ds_type: GeoPackageDatasetTypes
lyr_name: str
lyr_type: str
ext_ref: str

def __init__(self,
Expand All @@ -137,6 +138,7 @@ def __init__(self,
description: str = None,
citation: str = None,
meta_data: MetaData = None,
lyr_type: str = None
) -> None:
"""
Initializes a GeoPackageDataset instance.
Expand All @@ -150,6 +152,7 @@ def __init__(self,
description (str, optional): A detailed description of the dataset. Defaults to None.
citation (str, optional): The citation information for the dataset. Defaults to None.
meta_data (MetaData, optional): The metadata associated with the dataset. Defaults to None.
lyr_type (str): The type of the dataset layer. This can be any string and it's used as a non-unique identifier to help with business logic xpaths
Returns:
None
Expand Down Expand Up @@ -178,14 +181,15 @@ def __init__(self,
description=description,
citation=citation,
meta_data=meta_data,
mandatory_id=False
mandatory_id=False,
)
if not ds_type or ds_type not in GeoPackageDatasetTypes.__dict__.values():
raise ValueError('Dataset type is required for Dataset')
if not lyr_name:
raise ValueError('Layer name is required for Dataset')

self.lyr_name = lyr_name
self.lyr_type = lyr_type
self.ds_type = ds_type
self.ext_ref = ext_ref

Expand All @@ -198,6 +202,7 @@ def from_xml(xml_node: ET.Element) -> GeopackageLayer:
"""
rsobj = RSObj.from_xml(xml_node)
lyr_name = xml_node.get('lyrName')
lyr_type = xml_node.get('type')

# if this is a dataset then the id will get picked up by the RSObj.from_xml
dataset = GeopackageLayer(lyr_name=lyr_name,
Expand All @@ -207,7 +212,8 @@ def from_xml(xml_node: ET.Element) -> GeopackageLayer:
summary=rsobj.summary,
description=rsobj.description,
citation=rsobj.citation,
meta_data=rsobj.meta_data
meta_data=rsobj.meta_data,
lyr_type=lyr_type,
)
return dataset

Expand All @@ -229,6 +235,8 @@ def to_xml(self) -> ET.Element:
xml_node = super().to_xml()

xml_node.set('lyrName', self.lyr_name)
if self.lyr_type:
xml_node.set('type', self.lyr_type)
if self.ext_ref:
xml_node.set('extRef', self.ext_ref)

Expand Down
2 changes: 1 addition & 1 deletion python/packages/rsxml/rsxml/project_xml/Project.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from rsxml.project_xml.QAQCEvent import QAQCEvent
from rsxml.project_xml.Warehouse import Warehouse

from rsxml.logging.logger import Logger
from rsxml import Logger


class Project(RSObj):
Expand Down
3 changes: 1 addition & 2 deletions python/packages/rsxml/rsxml/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from lxml import etree
except ImportError:
etree = None
from rsxml import Logger
from rsxml.logging.logger import Logger
from rsxml.constants import XSD_URL


Expand Down Expand Up @@ -80,4 +80,3 @@ def validate_project_file(project_file_path: str):
raise e

return validate_xml(xml, xsd)

3 changes: 3 additions & 0 deletions python/packages/rsxml/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
url='https://github.com/Riverscapes/RiverscapesXML',
packages=[
'rsxml',
'rsxml.util',
'rsxml.dotenv',
'rsxml.rspaths',
'rsxml.logging',
'rsxml.debug',
'rsxml.project_xml'
Expand Down
1 change: 1 addition & 0 deletions python/packages/rsxml/tests/test_project_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def test_geopackage_add_layer(self):
ds_type=project_xml.GeoPackageDatasetTypes.RASTER,
ext_ref='test_path/test.tiff',
lyr_name='test_layer',
lyr_type='test_type',
meta_data=MetaData(values=[
project_xml.Meta(name='test_key', value='test_no_type'),
project_xml.Meta(name='test_key2', value='test_valid_type', type='filepath')
Expand Down

0 comments on commit 8ab7d95

Please sign in to comment.