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: Add support to arithmetic expressions #5831

Merged
merged 38 commits into from Sep 4, 2019

Conversation

jbo-ads
Copy link
Member

@jbo-ads jbo-ads commented Jul 1, 2019

This pull request aims at adding support to arithmetic expressions in SLD documents read by MapServer. It implements the first section of MS RFC 124: Improving SLD Support in MapServer.

jbo-ads added 30 commits July 1, 2019 15:19
@sdlime
Copy link
Member

sdlime commented Jul 5, 2019

At first glance this looks good. I kinda wish we could just extend the binding object to be more general to handle both a straight item and an expression but this work doesn't preclude that from happening at a later date. --Steve

@sdlime
Copy link
Member

sdlime commented Jul 5, 2019

Do you have a feeling about how easy it would be to add this functionality in a more general sense? I think that should be done even if not part of your work. There are also at least one label property where this would be a nice addition (SIZE). --Steve

@jbo-ads
Copy link
Member Author

jbo-ads commented Jul 5, 2019

Do you mean extending the binding object instead of having both bindings and exprBindings? I think the changes would affect mainly the MapFile parsing step. As a side effect, expressions would be allowed in MapFile in places where currently only attributes and literals are.

@sdlime
Copy link
Member

sdlime commented Jul 8, 2019

That's what I was thinking but it's probably not worth the effort and you're right that expressions for things like colors don't make sense. Although enabling an expression binding would still need to be done in the mapfile parsing code (my second comment). I can take that piece on...

for(i=0; i<MS_LABEL_BINDING_LENGTH; i++) {
label->bindings[i].item = NULL;
label->bindings[i].index = -1;
msInitExpression(&(label->exprBindings[i]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this freed ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I added msFreeExpression() in freeLabel() function.

for(i=0; i<MS_STYLE_BINDING_LENGTH; i++) {
style->bindings[i].item = NULL;
style->bindings[i].index = -1;
msInitExpression(&(style->exprBindings[i]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this freed ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again. I added msFreeExpression() in freeStyle() function.

@jbo-ads
Copy link
Member Author

jbo-ads commented Jul 9, 2019

@sdlime As an exercise I am currently investigating how easy it would be to add expressions on label size. It has been a long time since I last played with lex and yacc :)

@jbo-ads
Copy link
Member Author

jbo-ads commented Jul 15, 2019

@sdlime I just added expression handling on Label Size. It only involves changes in mapfile.c. It should not be difficult to propagate these changes on other properties. Tell me if you want that I include this commit in this pull request.

@sdlime
Copy link
Member

sdlime commented Jul 16, 2019

@sdlime I just added expression handling on Label Size. It only involves changes in mapfile.c. It should not be difficult to propagate these changes on other properties. Tell me if you want that I include this commit in this pull request.

I think we should add this capability across the board - I can help too. I think folks would be bummed if this nice addition was SLD-only. That should be a broader goal. I would include that commit in the pull request.

Which got me wondering - how do things behave if an object already has an expression binding and then SLD defines another one? I would guess it would just free the old one and install the new one (essentially overwrite). Or this use case, there's an existing attribute binding and then SLD defines an expression binding? This might be a reason to have a single binding object?

--Steve

@jbo-ads
Copy link
Member Author

jbo-ads commented Jul 17, 2019

Commit is included in this pull request.

I didn't check these specific use cases. They are worth a test in msautotest. An expression binding from SLD overwrites the one in MapFile and takes precedence over a simple binding from Mapfile.

@sdlime
Copy link
Member

sdlime commented Jul 19, 2019

Thinking about it more doesn't SLD just create a bunch of new classes in a layer? (I'm not an SLD user) I mean, if classes are already defined then I'd guess they are removed and new ones created.

@jbo-ads
Copy link
Member Author

jbo-ads commented Jul 23, 2019

I just checked the code: if a layer is defined both in MapFile and SLD, all classes from MapFile inside that layer are just removed and replaced by classes from SLD.

@sdlime
Copy link
Member

sdlime commented Jul 23, 2019

I think we should go ahead and merge this code. Then we can work on a separate pull request that exposes the expression binding to more general mapfile processing (using your work in labels as a pattern). --Steve

@geographika
Copy link
Member

@sdlime I just added expression handling on Label Size. It only involves changes in mapfile.c. It should not be difficult to propagate these changes on other properties. Tell me if you want that I include this commit in this pull request.

@jbo-ads - some excellent new features within this pull request.
One property that would really benefit from being set by expressions is STYLE>SIZE. There are many cases where symbol size depends on an attribute, but the attribute itself has no relation to a MapServer style size.

@jbo-ads
Copy link
Member Author

jbo-ads commented Aug 8, 2019

@geographika - If you don't mind waiting until september, I can add expression handling on STYLE->SIZE just like on LABEL->SIZE.

@sdlime
Copy link
Member

sdlime commented Aug 8, 2019

Could merge now and add style->size as another pull request...

@geographika
Copy link
Member

@geographika - If you don't mind waiting until september, I can add expression handling on STYLE->SIZE just like on LABEL->SIZE.

@jbo-ads - whenever you get a chance works for me! As @sdlime says don't let it hold up merging this work.

@rouault
Copy link
Contributor

rouault commented Aug 13, 2019

Unless someone objects, I'm considering pressing the 'Merge' button by tomorrow

@sdlime
Copy link
Member

sdlime commented Aug 13, 2019 via email

@rouault
Copy link
Contributor

rouault commented Sep 4, 2019

I guess we should squash the commits into a single one as the commit history in the PR is a bit messy ?

@jbo-ads
Copy link
Member Author

jbo-ads commented Sep 4, 2019

It makes sense. Commit history was useful only for me while implementing the feature.

@rouault rouault merged commit 4fbd7ae into MapServer:master Sep 4, 2019
@rouault
Copy link
Contributor

rouault commented Sep 4, 2019

Squashed and merged !

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

Successfully merging this pull request may close these issues.

None yet

4 participants