diff --git a/sigpac_tools/anotate.py b/sigpac_tools/anotate.py index 9a62427..2b5ad63 100644 --- a/sigpac_tools/anotate.py +++ b/sigpac_tools/anotate.py @@ -47,29 +47,22 @@ def __query( KeyError If the layer is not supported """ + id = "" match layer.lower(): case "parcela": logger.info("Searching for the parcel specified") - url = f"{BASE_URL}/fega/ServiciosVisorSigpac/LayerInfo" - params = { - "layer": layer, - "id": f"{province},{municipality},{aggregate},{zone},{polygon},{parcel}", - } - response = requests.get(url, params=params) - return response.json() + id = f"{province},{municipality},{aggregate},{zone},{polygon},{parcel}" case "recinto": logger.info("Searching for the enclosure specified") - url = f"{BASE_URL}/fega/ServiciosVisorSigpac/LayerInfo" - params = { - "layer": layer, - "id": f"{province},{municipality},{aggregate},{zone},{polygon},{parcel},{enclosure}", - } - response = requests.get(url, params=params) - return response.json() + id = f"{province},{municipality},{aggregate},{zone},{polygon},{parcel},{enclosure}" case _: raise KeyError( "Layer not supported. Supported layers: ['parcela', 'recinto']" ) + + url = f"{BASE_URL}/fega/serviciosvisorsigpac/layerinfo/{layer}/{id}" + response = requests.get(url) + return response.json() def get_metadata(layer: str, data: dict): diff --git a/sigpac_tools/search.py b/sigpac_tools/search.py index 703070c..dbb4b47 100644 --- a/sigpac_tools/search.py +++ b/sigpac_tools/search.py @@ -48,14 +48,14 @@ def search(data: dict) -> dict: if parc: logger.info("Searching for the parcel specified") response = requests.get( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/recintos/{prov}/{muni}/0/0/{polg}/{parc}" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/recintos/{prov}/{muni}/0/0/{polg}/{parc}" ) geojson = response.json() return geojson else: logger.info(f"Searching for the parcels of the polygon {polg}") response = requests.get( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/parcelas/{prov}/{muni}/0/0/{polg}" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/parcelas/{prov}/{muni}/0/0/{polg}" ) geojson = response.json() return geojson @@ -64,21 +64,21 @@ def search(data: dict) -> dict: f"Searching for the polygons of the municipality {muni}" ) response = requests.get( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/poligonos/{prov}/{muni}/0/0" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/poligonos/{prov}/{muni}/0/0" ) geojson = response.json() return geojson else: logger.info(f"Searching for the municipalities of the province {prov}") response = requests.get( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/municipios/{prov}" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/municipios/{prov}" ) geojson = response.json() return geojson else: logger.info(f"Searching for the provinces of the community {comm}") response = requests.get( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/provincias/{comm}" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/provincias/{comm}" ) geojson = response.json() return geojson diff --git a/tests/test_search.py b/tests/test_search.py index 6530192..0f29b2f 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -22,7 +22,7 @@ def test_search_provinces(self, mock_get): search(data) mock_get.assert_called_once_with( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/provincias/1.geojson" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/provincias/1" ) @patch("sigpac_tools.search.requests.get") @@ -35,7 +35,7 @@ def test_search_municipalities(self, mock_get): search(data) mock_get.assert_called_once_with( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/municipios/1.geojson" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/municipios/1" ) @patch("sigpac_tools.search.requests.get") @@ -48,7 +48,7 @@ def test_search_polygons(self, mock_get): search(data) mock_get.assert_called_once_with( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/poligonos/1/1/0/0.geojson" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/poligonos/1/1/0/0" ) @patch("sigpac_tools.search.requests.get") @@ -61,7 +61,7 @@ def test_search_parcels(self, mock_get): search(data) mock_get.assert_called_once_with( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/parcelas/1/1/0/0/1.geojson" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/parcelas/1/1/0/0/1" ) @patch("sigpac_tools.search.requests.get") @@ -74,7 +74,7 @@ def test_search_specific_parcel(self, mock_get): search(data) mock_get.assert_called_once_with( - f"{BASE_URL}/fega/ServiciosVisorSigpac/query/recintos/1/1/0/0/1/1.geojson" + f"{BASE_URL}/fega/serviciosvisorsigpac/query/recintos/1/1/0/0/1/1" ) def test_missing_community_and_province(self):