Skip to content

Commit

Permalink
FIX: numpy floats parsed incorrectly (#955)
Browse files Browse the repository at this point in the history
* FIX: numpy floats parsed incorrectly

* TST: add test_build_getmap_request_bbox_precision
  • Loading branch information
juhi24 authored Nov 7, 2024
1 parent c71c5f7 commit cdd92cd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion owslib/coverage/wcs110.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def getCoverage(self, identifier=None, bbox=None, time=None, format=None, store=
request['identifier'] = identifier
# request['identifier'] = ','.join(identifier)
if bbox:
request['boundingbox'] = ','.join([repr(x) for x in bbox])
request['boundingbox'] = ','.join([str(x) for x in bbox])
if time:
request['timesequence'] = ','.join(time)
request['format'] = format
Expand Down
2 changes: 1 addition & 1 deletion owslib/feature/wfs100.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def getfeature(
if featureid:
request["featureid"] = ",".join(featureid)
elif bbox and typename:
request["bbox"] = ",".join([repr(x) for x in bbox])
request["bbox"] = ",".join([str(x) for x in bbox])
elif filter and typename:
request["filter"] = str(filter)

Expand Down
2 changes: 1 addition & 1 deletion owslib/map/wms111.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __build_getmap_request(self, layers=None, styles=None, srs=None, bbox=None,
request['height'] = str(size[1])

request['srs'] = str(srs)
request['bbox'] = ','.join([repr(x) for x in bbox])
request['bbox'] = ','.join([str(x) for x in bbox])
request['format'] = str(format)
request['transparent'] = str(transparent).upper()
request['exceptions'] = str(exceptions)
Expand Down
2 changes: 1 addition & 1 deletion owslib/map/wms130.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __build_getmap_request(self, layers=None, styles=None, srs=None, bbox=None,

# remapping the srs to crs for the request
request['crs'] = str(srs)
request['bbox'] = ','.join([repr(x) for x in bbox])
request['bbox'] = ','.join([str(x) for x in bbox])
request['format'] = str(format)
request['transparent'] = str(transparent).upper()
request['exceptions'] = str(exceptions)
Expand Down
21 changes: 21 additions & 0 deletions tests/test_wms_getmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from tests.utils import service_ok

from owslib.wms import WebMapService
from owslib.map.wms130 import WebMapService_1_3_0
from owslib.util import ServiceException
from owslib.util import ResponseWrapper

Expand All @@ -12,6 +13,26 @@
NCWMS2_URL = "http://wms.stccmop.org:8080/ncWMS2/wms"


@pytest.fixture
def wms():
return WebMapService_1_3_0(SERVICE_URL, version='1.3.0')


def test_build_getmap_request_bbox_precision(wms):
bbox = (-126.123456789, 24.123456789, -66.123456789, 50.123456789)
bbox_yx = (bbox[1], bbox[0], bbox[3], bbox[2])
request = wms._WebMapService_1_3_0__build_getmap_request(
layers=['layer1'],
styles=['default'],
srs='EPSG:4326',
bbox=bbox,
format='image/jpeg',
size=(250, 250),
transparent=True
)
assert request['bbox'] == ','.join(map(str, bbox_yx))


@pytest.mark.online
@pytest.mark.skipif(not service_ok(SERVICE_URL),
reason="WMS service is unreachable")
Expand Down

0 comments on commit cdd92cd

Please sign in to comment.