Created
April 19, 2024 10:08
-
-
Save aborruso/fc0b4f7835bd2da79a957faf061b7f2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<gml:FeatureCollection xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"> | |
<gml:featureMember> | |
<gml:Point srsName="urn:ogc:def:crs:EPSG:6.12:4326"> | |
<gml:coordinates>12.4924,41.8902</gml:coordinates> <!-- Longitudine, Latitudine del Colosseo a Roma --> | |
</gml:Point> | |
</gml:featureMember> | |
</gml:FeatureCollection> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from owslib.wps import WebProcessingService, ComplexDataInput | |
import traceback | |
import requests | |
# Configura il logging | |
logging.basicConfig(level=logging.DEBUG) | |
# Indirizzo del servizio WPS | |
url = 'http://wms.pcn.minambiente.it/wps' | |
# Connetti al servizio WPS | |
wps = WebProcessingService(url, skip_caps=True) | |
# Leggi il contenuto del file GML | |
with open('test_input.gml', 'r') as file: | |
gml_content = file.read() | |
# Configura i parametri | |
inputs = [ | |
('SourceCRS', 'urn:ogc:def:crs:EPSG:6.12:4326'), | |
('TargetCRS', 'urn:ogc:def:crs:EPSG:6.12:25832'), | |
('InputData', ComplexDataInput(value=gml_content, mimeType='text/xml; subtype=gml/3.1.1')), | |
('TestTransformation', 'False') | |
] | |
# Imposta l'identificatore del processo | |
process_id = 'TransformCoordinates' | |
# Tenta di eseguire la trasformazione | |
try: | |
execution = wps.execute(identifier=process_id, inputs=inputs) | |
wps.monitor_execution(execution) | |
output = execution.processOutputs[0].data | |
print("Output:") | |
print(output) | |
except Exception as e: | |
print("Errore durante l'esecuzione del WPS:") | |
print(traceback.format_exc()) | |
# Stampa la risposta grezza per il debugging | |
print("Tentativo di recupero della risposta grezza:") | |
try: | |
response = requests.post(url, data={'request': gml_content}) # Assicurati che i dati siano formati correttamente per la POST | |
print(response.text) # Stampa la risposta testuale grezza | |
except Exception as e: | |
print("Impossibile recuperare la risposta grezza:") | |
print(str(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment