Skip to content

Iso19115

ISO19115Extract

Bases: ExtractionMethod

Takes a URL and calls out to URL to retrieve the iso19115 record.

Method name: iso19115

Example configuration

.. code-block:: yaml

- method: iso19115
  inputs:
    url: $url
    dates:
      - key: './/gml:beginPosition'
        output_key: start_datetime
Source code in extraction_methods/plugins/iso19115.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class ISO19115Extract(ExtractionMethod):
    """
    Takes a URL and calls out to URL to retrieve the iso19115 record.

    **Method name:** ``iso19115``

    Example configuration:
        .. code-block:: yaml

            - method: iso19115
              inputs:
                url: $url
                dates:
                  - key: './/gml:beginPosition'
                    output_key: start_datetime
    """

    input_class = ISO19115Input

    @update_input
    def run(self, body: dict[str, Any]) -> dict[str, Any]:

        # Retrieve the ISO 19115 record
        response = httpx.get(self.input.url, timeout=self.input.request_timeout)

        if not response.status_code == 200:
            LOGGER.debug(
                "Request %s failed with response: %s", self.input.url, response.text
            )
            return body

        iso_record = ET.fromstring(response.text)

        # Extract the keys
        for extraction_term in self.input.dates:
            value = iso_record.find(extraction_term.key, iso19115_ns)

            if value is not None:
                body[extraction_term.output_key] = value.text

        return body

ISO19115Input

Bases: Input

Model for ISO19115 Date Input.

Parameters:

Name Type Description Default
url str

Url for record store.

required
dates list[KeyOutputKey]

list of dates to extract.

required
request_timeout int

request time out.

15
Source code in extraction_methods/plugins/iso19115.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class ISO19115Input(Input):
    """
    Model for ISO19115 Date Input.
    """

    url: str = Field(
        description="Url for record store.",
    )
    dates: list[KeyOutputKey] = Field(
        description="list of dates to extract.",
    )
    request_timeout: int = Field(
        default=15,
        description="request time out.",
    )