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

SLD stroke-width is not converted to 'pixels' on layer publishing #183

Open
kitzilla opened this issue Jun 26, 2015 · 0 comments
Open

SLD stroke-width is not converted to 'pixels' on layer publishing #183

kitzilla opened this issue Jun 26, 2015 · 0 comments

Comments

@kitzilla
Copy link

When publishing a layer to GeoServer through Opengeo Explorer, some css parameters like stroke-width and stroke-dasharray are not converted from QGIS's unit system (millimeters) to GeoServer's (pixels).

Since I am new to git and I could not push my fixes to this repo, I would paste them here as a suggestion,

To opengeo/qgis/sldadapter.py
_1. Add the following function

def convertMMtoPx(regexPattern, string):
    for m in re.finditer(regexPattern, string):
        if m.lastindex < 1:
            continue
        string = '%s%s%s' % (string[:m.start(1)], float(m.group(1)) * SIZE_FACTOR, string[m.end(1):])
    return string

_2. Insert the following lines to adaptQgsToGs function (between line 40 and 41)

    sld = convertMMtoPx(r'<CssParameter name="stroke-width">\s*(\d+\.?\d*|\d*\.\d+)\s*</CssParameter>', sld)
    sld = convertMMtoPx(r'<CssParameter name="stroke-dashoffset">\s*(\d+\.?\d*|\d*\.\d+)\s*</CssParameter>', sld)
    for m in re.finditer(r'<CssParameter name="stroke-dasharray">([\s\d\.]+)</CssParameter>', sld):
        if m.lastindex > 0:
            nums = [ str(float(n) * SIZE_FACTOR) for n in re.split(r'\s+', m.group(1)) ] 
            sld = '%s<CssParameter name="stroke-dasharray">%s</CssParameter>%s' % (sld[:m.start()], ' '.join(nums), sld[m.end():])
@kitzilla kitzilla changed the title SLD stroke-width is not converted to 'pixels' on publishing layer SLD stroke-width is not converted to 'pixels' on layer publishing Jun 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant