arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

OGC Feature Server URL - rejects valid servers

Open jr-elliott opened this issue 8 months ago • 1 comments

Describe the bug In layers/_ogc/_service.py, in the OGCCollectionClass, it checks the provided URL to ensure it has "ogcfeatureserver" in it and that it ends in a number. This invalidates a lot of servers that do work, such as the server provided by OGC itself.

In testing I have removed these assert statements (or run Python optimized with the -O flag), and was able to connect and pull data from servers that do not meet these URL requirements.

To Reproduce

from arcgis.layers import OGCFeatureService

feature_layer = OGCFeatureService("https://demo.ldproxy.net/daraa")

print(feature_layer.properties)

error:

Traceback (most recent call last):
  File "[HIDDEN].py", line 3, in <module>
    feature_layer = OGCFeatureService("https://demo.ldproxy.net/daraa")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[HIDDEN]/.venv/lib/python3.11/site-packages/arcgis/layers/_ogc/_service.py", line 227, in __init__
    assert str(url).lower().endswith("ogcfeatureserver")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Expected behavior It should connect to the server and be able to pull data. When run with python -O, the beginning of the output is:

{'title': 'Daraa', 'description': 'This is a test dataset used in the Open Portrayal Framework thread in the OGC Testbed-15 as well as the OGC Vector Tiles Pilot Phase 2. The data is based on OpenStreetMap data from the region of Daraa, Syria, converted to the Topographic Data Store schema of NGA.', 'attribution': 'US National Geospatial Intelligence Agency (NGA)', 'extent':

Platform (please complete the following information):

  • Python API Version 2.4.1

jr-elliott avatar Jun 05 '25 18:06 jr-elliott

Hi, related to this (also running Python arcgis API version 2.4.1), if I run something like

from arcgis.layers import OGCCollection
feature_collection = OGCCollection(
	"https://demo.ldproxy.net/daraa/collections/AeronauticCrv"
)
print(feature_collection)

I get the following error:

    def __init__(self, url: str, gis: GIS = None) -> "OGCCollection":
        """Constructor"""
        assert (
>           str(url).lower().find("ogcfeatureserver") > -1
            and os.path.basename(url).isdigit()
        )
E       AssertionError

If I remove the assert statements in the constructor of the OGCCollection class, the code works. Can you all also please remove these assert statements from the source code? In many OGC API servers, the collection name is often not an integer.

Modified constructor that works:

    def __init__(self, url: str, gis: GIS = None) -> "OGCCollection":
        """Constructor"""
        if gis is None:
            gis = _env.active_gis or GIS()
        self._gis = gis
        self._url = url

nsshah1288 avatar Jun 06 '25 16:06 nsshah1288

Fixed for the next release (2.4.2)

nanaeaubry avatar Sep 17 '25 09:09 nanaeaubry