Skip to content

Commit

Permalink
Merge pull request #128 from wickes1/feat/featurestore-abstract-keywords
Browse files Browse the repository at this point in the history
feat: publish and edit featurestore with abstract and keywords
  • Loading branch information
iamtekson authored Sep 27, 2023
2 parents 5a3db89 + d19fe13 commit 4e5538d
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions geo/Geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1798,8 +1798,11 @@ def publish_featurestore(
workspace: Optional[str] = None,
title: Optional[str] = None,
advertised: Optional[bool] = True,
abstract: Optional[str] = None,
keywords: Optional[List[str]] = None,
):
"""
Publish a featurestore to geoserver.
Parameters
----------
Expand All @@ -1808,6 +1811,8 @@ def publish_featurestore(
workspace : str, optional
title : str, optional
advertised : bool, optional
abstract : str, optional
keywords : list, optional
Returns
-------
Expand All @@ -1826,13 +1831,21 @@ def publish_featurestore(
self.service_url, workspace, store_name
)

layer_xml = """<featureType>
<name>{}</name>
<title>{}</title>
<advertised>{}</advertised>
</featureType>""".format(
pg_table, title, advertised
)
abstract_xml = f"<abstract>{abstract}</abstract>" if abstract else ""
keywords_xml = ""
if keywords:
keywords_xml = "<keywords>"
for keyword in keywords:
keywords_xml += f"<string>{keyword}</string>"
keywords_xml += "</keywords>"

layer_xml = f"""<featureType>
<name>{pg_table}</name>
<title>{title}</title>
<advertised>{advertised}</advertised>
{abstract_xml}
{keywords_xml}
</featureType>"""
headers = {"content-type": "text/xml"}

r = requests.post(
Expand All @@ -1853,6 +1866,8 @@ def edit_featuretype(
pg_table: str,
name: str,
title: str,
abstract: Optional[str] = None,
keywords: Optional[List[str]] = None,
):
"""
Expand All @@ -1863,6 +1878,8 @@ def edit_featuretype(
pg_table : str
name : str
title : str
abstract : str, optional
keywords : list, optional
Returns
-------
Expand All @@ -1877,12 +1894,20 @@ def edit_featuretype(
self.service_url, workspace, store_name, pg_table
)

layer_xml = """<featureType>
<name>{}</name>
<title>{}</title>
</featureType>""".format(
name, title
)
# Create XML for abstract and keywords
abstract_xml = f"<abstract>{abstract}</abstract>" if abstract else ""
keywords_xml = ""
if keywords:
keywords_xml = "<keywords>"
for keyword in keywords:
keywords_xml += f"<string>{keyword}</string>"
keywords_xml += "</keywords>"

layer_xml = f"""<featureType>
<name>{name}</name>
<title>{title}</title>
{abstract_xml}{keywords_xml}
</featureType>"""
headers = {"content-type": "text/xml"}

r = requests.put(
Expand Down

0 comments on commit 4e5538d

Please sign in to comment.