-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set world bounding box on GeoServer layer if DB table is empty
- Loading branch information
Showing
15 changed files
with
179 additions
and
19 deletions.
There are no files selected for viewing
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] |
Binary file not shown.
Binary file not shown.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import os | ||
import pytest | ||
import requests | ||
from owslib.wms import WebMapService | ||
from layman import settings | ||
from layman.layer.geoserver import wms as gs_wms | ||
from test import process, process_client | ||
from test.data import wfs as wfs_data_util | ||
|
||
|
||
def get_shp_file_paths(shp_file_path): | ||
extensions = ['dbf', 'prj', 'qpj', 'shx'] | ||
root, shp_ext = os.path.splitext(shp_file_path) | ||
result = [f"{root}.{ext}" for ext in extensions] | ||
result.append(shp_file_path) | ||
return result | ||
|
||
|
||
def assert_non_empty_bbox(bbox): | ||
assert bbox[0] < bbox[2] and bbox[1] < bbox[3] | ||
|
||
|
||
def assert_wms_layer(workspace, layername, exp_title): | ||
wms = WebMapService(gs_wms.get_wms_url(workspace), gs_wms.VERSION) | ||
assert layername in wms.contents | ||
wms_layer = wms[layername] | ||
assert wms_layer.title == exp_title | ||
assert_non_empty_bbox(wms_layer.boundingBox) | ||
assert_non_empty_bbox(wms_layer.boundingBoxWGS84) | ||
return wms_layer | ||
|
||
|
||
def wfs_t_insert_point(workspace, layername): | ||
wfs_t_data = wfs_data_util.get_wfs20_insert_points(workspace, layername) | ||
wfs_t_url = f"http://{settings.LAYMAN_SERVER_NAME}/geoserver/{workspace}/wfs?request=Transaction" | ||
wfs_t_headers = { | ||
'Accept': 'text/xml', | ||
'Content-type': 'text/xml', | ||
} | ||
r = requests.post(wfs_t_url, | ||
data=wfs_t_data, | ||
headers=wfs_t_headers) | ||
assert r.status_code == 200 | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def ensure_layman(): | ||
layman_process = process.start_layman() | ||
yield | ||
process.stop_process(layman_process) | ||
|
||
|
||
@pytest.mark.parametrize('layername, file_paths', [ | ||
('empty', get_shp_file_paths('sample/layman.layer/empty.shp')), | ||
('single_point', get_shp_file_paths('sample/layman.layer/single_point.shp')), | ||
]) | ||
@pytest.mark.usefixtures('ensure_layman') | ||
def test_empty_shapefile(layername, file_paths): | ||
workspace = 'test_empty_bbox_workspace' | ||
title = layername | ||
|
||
process_client.publish_layer(workspace, layername, file_paths=file_paths) | ||
|
||
wms_layer = assert_wms_layer(workspace, layername, title) | ||
native_bbox = wms_layer.boundingBox | ||
wgs_bbox = wms_layer.boundingBoxWGS84 | ||
|
||
title = 'new title' | ||
process_client.patch_layer(workspace, layername, title=title) | ||
wms_layer = assert_wms_layer(workspace, layername, title) | ||
assert wms_layer.boundingBox == native_bbox | ||
assert wms_layer.boundingBoxWGS84 == wgs_bbox | ||
|
||
wfs_t_insert_point(workspace, layername) | ||
wms_layer = assert_wms_layer(workspace, layername, title) | ||
assert wms_layer.boundingBox == native_bbox | ||
assert wms_layer.boundingBoxWGS84 == wgs_bbox | ||
|
||
process_client.delete_layer(workspace, layername) |
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