django-gisserver 2.1__py3-none-any.whl → 2.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gisserver/parsers/ast.py CHANGED
@@ -6,7 +6,7 @@ For example, the FES filter syntax can be processed into objects that build an O
6
6
  Python classes can inherit :class:`AstNode` and register themselves as the parser/handler
7
7
  for a given tag. Both normal Python classes and dataclass work,
8
8
  as long as it has an :meth:`AstNode.from_xml` class method.
9
- The custom `from_xml()` method should copy the XML data into local attributes.
9
+ The custom ``from_xml()`` method should copy the XML data into local attributes.
10
10
 
11
11
  Next, when :meth:`TagRegistry.node_from_xml` is called,
12
12
  it will detect which class the XML Element refers to and initialize it using the ``from_xml()`` call.
@@ -58,7 +58,7 @@ class TagNameEnum(Enum):
58
58
  """Cast the element tag name into the enum member.
59
59
 
60
60
  This translates the element name
61
- such as``{http://www.opengis.net/fes/2.0}PropertyIsEqualTo``
61
+ such as ``{http://www.opengis.net/fes/2.0}PropertyIsEqualTo``
62
62
  into a ``PropertyIsEqualTo`` member.
63
63
  """
64
64
  tag_name = element.tag
@@ -90,6 +90,7 @@ class AstNode:
90
90
  an XML tag into a Python (data) class.
91
91
  """
92
92
 
93
+ #: Default namespace of the element and subclasses, if not given by ``@tag_registry.register()``.
93
94
  xml_ns: xmlns | str | None = None
94
95
 
95
96
  _xml_tags = []
@@ -99,6 +100,8 @@ class AstNode:
99
100
  """Tell the default tag by which this class is registered"""
100
101
  return cls._xml_tags[0]
101
102
 
103
+ xml_name.__doc__ = "Tell the default tag by which this class is registered"
104
+
102
105
  def __init_subclass__(cls):
103
106
  # Each class level has a fresh list of supported child tags.
104
107
  cls._xml_tags = []
@@ -124,7 +127,7 @@ class AstNode:
124
127
 
125
128
  @classmethod
126
129
  def get_tag_names(cls) -> list[str]:
127
- """Provide all known XMl tags that this code can parse."""
130
+ """Provide all known XML tags that this code can parse."""
128
131
  try:
129
132
  # Because a cached class property is hard to build
130
133
  return _KNOWN_TAG_NAMES[cls]
@@ -233,14 +236,14 @@ class TagRegistry:
233
236
  def node_from_xml(self, element: NSElement, allowed_types: tuple[type[A]] | None = None) -> A:
234
237
  """Find the ``AstNode`` subclass that corresponds to the given XML element,
235
238
  and initialize it with the element. This is a convenience shortcut.
236
- ``"""
239
+ """
237
240
  node_class = self.resolve_class(element, allowed_types)
238
241
  return node_class.from_xml(element)
239
242
 
240
243
  def resolve_class(
241
244
  self, element: NSElement, allowed_types: tuple[type[A]] | None = None
242
245
  ) -> type[A]:
243
- """Find the ``AstNode`` subclass that corresponds to the given XML element."""
246
+ """Find the :class:`AstNode` subclass that corresponds to the given XML element."""
244
247
  try:
245
248
  node_class = self.parsers[element.tag]
246
249
  except KeyError:
@@ -227,7 +227,7 @@ class Operator(AstNode):
227
227
 
228
228
  @dataclass
229
229
  class IdOperator(Operator):
230
- """List of :class:`~gisserver.parsers.fes20.identifers.ResourceId`` objects.
230
+ """List of :class:`~gisserver.parsers.fes20.identifers.ResourceId` objects.
231
231
 
232
232
  A ``<fes:Filter>`` only has a single predicate.
233
233
  Hence, this operator is used to wrap the ``<fes:ResourceId>`` elements in the syntax::
@@ -89,7 +89,13 @@ class GEOSGMLGeometry(AbstractGeometry):
89
89
  # This avoids having to support the whole GEOS logic.
90
90
  geos_data = GEOSGeometry.from_gml(tostring(element))
91
91
  geos_data.srid = srs.srid
92
- CRS.tag_geometry(geos_data, axis_order=AxisOrder.AUTHORITY)
92
+
93
+ # Using the WFS 2 format (urn:ogc:def:crs:EPSG::4326"), coordinates should be latitude/longitude.
94
+ # However, when providing legacy formats like srsName="EPSG:4326",
95
+ # input is assumed to be in legacy longitude/latitude axis ordering too.
96
+ # This reflects what GeoServer does: https://docs.geoserver.org/main/en/user/services/wfs/axis_order.html
97
+ if not srs.force_xy:
98
+ CRS.tag_geometry(geos_data, axis_order=AxisOrder.AUTHORITY)
93
99
  return cls(srs=srs, geos_data=geos_data)
94
100
 
95
101
  def __repr__(self):
@@ -48,7 +48,9 @@ class AdhocQuery(QueryExpression):
48
48
  <fes:SortBy>...</fes:SortBy>
49
49
  </wfs:Query>
50
50
 
51
- And supports the KVP syntax::
51
+ And supports the KVP syntax:
52
+
53
+ .. code-block:: urlencoded
52
54
 
53
55
  ?SERVICE=WFS&...&TYPENAMES=ns:myType&FILTER=...&SORTBY=...&SRSNAME=...&PROPERTYNAME=...
54
56
  ?SERVICE=WFS&...&TYPENAMES=ns:myType&BBOX=...&SORTBY=...&SRSNAME=...&PROPERTYNAME=...