Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish SLD in dedicated WMS GeoServer workspace #237

Merged
merged 14 commits into from
Feb 4, 2021
Merged
15 changes: 7 additions & 8 deletions src/layman/layer/filesystem/thumbnail.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import os
import pathlib
import requests
from urllib.parse import urljoin
from layman import settings
from flask import current_app

from layman import patch_mode
from layman.util import url_for
from . import util
from . import util, input_file
from layman.common.filesystem import util as common_util
from . import input_file
from ..geoserver import wms as geoserver_wms

LAYER_SUBDIR = __name__.split('.')[-1]

Expand Down Expand Up @@ -65,11 +63,12 @@ def get_layer_thumbnail_path(username, layername):
return os.path.join(thumbnail_dir, layername + '.png')


def generate_layer_thumbnail(username, layername):
def generate_layer_thumbnail(workspace, layername):
geoserver_workspace = geoserver_wms.get_geoserver_workspace(workspace)
headers = {
settings.LAYMAN_GS_AUTHN_HTTP_HEADER_ATTRIBUTE: settings.LAYMAN_GS_USER,
}
wms_url = urljoin(settings.LAYMAN_GS_URL, username + '/ows')
wms_url = urljoin(settings.LAYMAN_GS_URL, geoserver_workspace + '/ows')
index-git marked this conversation as resolved.
Show resolved Hide resolved
from layman.layer.geoserver.util import wms_proxy
from layman.common.geoserver import get_layer_thumbnail, get_layer_square_bbox
wms = wms_proxy(wms_url, headers=headers)
Expand All @@ -84,8 +83,8 @@ def generate_layer_thumbnail(username, layername):
# format='image/png',
# transparent=True,
# )
ensure_layer_thumbnail_dir(username, layername)
tn_path = get_layer_thumbnail_path(username, layername)
ensure_layer_thumbnail_dir(workspace, layername)
tn_path = get_layer_thumbnail_path(workspace, layername)
# out = open(tn_path, 'wb')
# out.write(tn_img.read())
# out.close()
Expand Down
1 change: 0 additions & 1 deletion src/layman/layer/filesystem/thumbnail_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


@pytest.mark.usefixtures('ensure_layman')
@pytest.mark.xfail(reason="Not yet implemented")
def test_sld_style_applied_in_thumbnail():
workspace = 'test_sld_style_applied_in_thumbnail_workspace'
layer = 'test_sld_style_applied_in_thumbnail_layer'
Expand Down