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

Binding feature attributes to styles and labels #2100

Closed
mapserver-bot opened this Issue Apr 3, 2012 · 13 comments

Comments

Projects
None yet
2 participants
@mapserver-bot

mapserver-bot commented Apr 3, 2012

Reporter: sdlime
Date: 2007/05/21 - 19:01
Trac URL: http://trac.osgeo.org/mapserver/ticket/2100
This bug will be used to track the implementation of the RFC 19 [http://mapserver.gis.umn.edu/development/rfc/ms-rfc-19/] implementation.

As of the creation of this bug an initial implementation has been checked in to the main trunk. It supports:

  • styles: color, outlinecolor, size and angle
  • labels: color, outlinecolor, size and angle

The main remaining tasks are:

  • adding a binding for a style symbol '''DONE'''
  • add more test cases (e.g. what happens when you bind a string to a numeric parameter)
  • removal of old properies (e.g. LABELITEMANGLE) and structure members in header files, code, lexer configuration and PHP/MapScript binding '''DONE'''
  • update label and style copy routines to handle bindings '''DONE'''
  • creation of setBinding and removeBinding MapScript methods for labelObj and styleObj objects (both Swig-based languages and PHP)
  • update write functions in mapfile.c to look for a binding
  • documentation
@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: hobu
Date: 2007/05/21 - 19:09
8cc9ec5 (r6126)

mapserver-bot commented Apr 3, 2012

Author: hobu
Date: 2007/05/21 - 19:09
8cc9ec5 (r6126)

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: assefa
Date: 2007/06/27 - 22:46
Steve,

Couple of points :

  1. Can you describe a bit what the set/remove bindings should do ? looking into this we could have a mapscript function that cold look like this
    $style->setBinding(MS_STYLE_BINDING_COLOR, "attribute_field")
    There could either be 2 functions in maputil.c one for style, one for label which would essantally do something like :
    msSetBindingStyle( MS_STYLE_BINDING_ENUM, field)

if (style->bindings[MS_STYLE_BINDING_COLOR].item)
{
free(style->bindings[MS_STYLE_BINDING_COLOR].item)
style->numbindings--;
}
style->bindings[MS_STYLE_BINDING_COLOR].item = strdup('field')
style->numbindings++;

removeBinding can also be done the same way, either having a separate function in maputil or using msSetBindingStyle with a NULL,

Could this work ?

  1. Is ther a possiblity to add the FONT parameter for binding ?

In both cases, I am will to add it and test with php mapscript since I need to use it for a client side tool.

Thanks

mapserver-bot commented Apr 3, 2012

Author: assefa
Date: 2007/06/27 - 22:46
Steve,

Couple of points :

  1. Can you describe a bit what the set/remove bindings should do ? looking into this we could have a mapscript function that cold look like this
    $style->setBinding(MS_STYLE_BINDING_COLOR, "attribute_field")
    There could either be 2 functions in maputil.c one for style, one for label which would essantally do something like :
    msSetBindingStyle( MS_STYLE_BINDING_ENUM, field)

if (style->bindings[MS_STYLE_BINDING_COLOR].item)
{
free(style->bindings[MS_STYLE_BINDING_COLOR].item)
style->numbindings--;
}
style->bindings[MS_STYLE_BINDING_COLOR].item = strdup('field')
style->numbindings++;

removeBinding can also be done the same way, either having a separate function in maputil or using msSetBindingStyle with a NULL,

Could this work ?

  1. Is ther a possiblity to add the FONT parameter for binding ?

In both cases, I am will to add it and test with php mapscript since I need to use it for a client side tool.

Thanks

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: assefa
Date: 2007/06/27 - 23:29
Another point I forgot : how would the save through mapscript work ? In my opinion, It would make sense to save the attribute bindings. Right now the it saves the last values that were using while rendering.

mapserver-bot commented Apr 3, 2012

Author: assefa
Date: 2007/06/27 - 23:29
Another point I forgot : how would the save through mapscript work ? In my opinion, It would make sense to save the attribute bindings. Right now the it saves the last values that were using while rendering.

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: sdlime
Date: 2007/06/28 - 06:49
Replying to [comment:7 assefa]:

Steve,

Couple of points :

  1. Can you describe a bit what the set/remove bindings should do ? looking into this we could have a mapscript function that cold look like this
    $style->setBinding(MS_STYLE_BINDING_COLOR, "attribute_field")
    There could either be 2 functions in maputil.c one for style, one for label which would essantally do something like :
    msSetBindingStyle( MS_STYLE_BINDING_ENUM, field)

if (style->bindings[MS_STYLE_BINDING_COLOR].item)
{
free(style->bindings[MS_STYLE_BINDING_COLOR].item)
style->numbindings--;
}
style->bindings[MS_STYLE_BINDING_COLOR].item = strdup('field')
style->numbindings++;

removeBinding can also be done the same way, either having a separate function in maputil or using msSetBindingStyle with a NULL,

Could this work ?

Yes, that's all I was thinking. I was going to write them as helper methods in the swig interface files, so in style.i you'd see:

int addBinding(int binding, char *item) {
if(!item) return MS_FAILURE;
if(binding < 0 || binding >= MS_STYLE_BINDING_LENGTH)
return MS_FAILURE;

if(this->bindings[binding].item) {
free(this->bindings[binding].item)
this->bindings[binding].index = -1;
this->numbindings--;
}

this->bindings[bindings].item = strdup(item);
this->numbindings++;

return MS_SUCCESS;
}

int removeBinding(int binding) {
if(binding < 0 || binding >= MS_STYLE_BINDING_LENGTH)
return MS_FAILURE;

if(this->bindings[binding].item) {
free(this->bindings[binding].item)
this->bindings[binding].index = -1;
this->numbindings--;
}

return MS_SUCCESS;
}

I hadn't planned on writing C functions to do it although we could. We'd need a seperate set/remove function for labels and styles unless we did something like:

int msSetBinding(void *obj, int binding, char *item, int max_bindings)

Would have to pass the MS_LABEL_BINDING_LENGTH or MS_STYLE_BINDING_LENGTH for max_bindings, or just ignore that test altogether (a bad idea I think).

The one problem I see is guaranteeing that the binding item index gets populated, which happens via msLayerWhichItems() at draw time. We'll see I guess.

  1. Is ther a possiblity to add the FONT parameter for binding ?

Yes, assuming you're talking font name (e.g. arial). I can do that for you if you wish. It's not hard but there are like 3 places you have to touch.

In both cases, I am will to add it and test with php mapscript since I need to use it for a client side tool.

Thanks

mapserver-bot commented Apr 3, 2012

Author: sdlime
Date: 2007/06/28 - 06:49
Replying to [comment:7 assefa]:

Steve,

Couple of points :

  1. Can you describe a bit what the set/remove bindings should do ? looking into this we could have a mapscript function that cold look like this
    $style->setBinding(MS_STYLE_BINDING_COLOR, "attribute_field")
    There could either be 2 functions in maputil.c one for style, one for label which would essantally do something like :
    msSetBindingStyle( MS_STYLE_BINDING_ENUM, field)

if (style->bindings[MS_STYLE_BINDING_COLOR].item)
{
free(style->bindings[MS_STYLE_BINDING_COLOR].item)
style->numbindings--;
}
style->bindings[MS_STYLE_BINDING_COLOR].item = strdup('field')
style->numbindings++;

removeBinding can also be done the same way, either having a separate function in maputil or using msSetBindingStyle with a NULL,

Could this work ?

Yes, that's all I was thinking. I was going to write them as helper methods in the swig interface files, so in style.i you'd see:

int addBinding(int binding, char *item) {
if(!item) return MS_FAILURE;
if(binding < 0 || binding >= MS_STYLE_BINDING_LENGTH)
return MS_FAILURE;

if(this->bindings[binding].item) {
free(this->bindings[binding].item)
this->bindings[binding].index = -1;
this->numbindings--;
}

this->bindings[bindings].item = strdup(item);
this->numbindings++;

return MS_SUCCESS;
}

int removeBinding(int binding) {
if(binding < 0 || binding >= MS_STYLE_BINDING_LENGTH)
return MS_FAILURE;

if(this->bindings[binding].item) {
free(this->bindings[binding].item)
this->bindings[binding].index = -1;
this->numbindings--;
}

return MS_SUCCESS;
}

I hadn't planned on writing C functions to do it although we could. We'd need a seperate set/remove function for labels and styles unless we did something like:

int msSetBinding(void *obj, int binding, char *item, int max_bindings)

Would have to pass the MS_LABEL_BINDING_LENGTH or MS_STYLE_BINDING_LENGTH for max_bindings, or just ignore that test altogether (a bad idea I think).

The one problem I see is guaranteeing that the binding item index gets populated, which happens via msLayerWhichItems() at draw time. We'll see I guess.

  1. Is ther a possiblity to add the FONT parameter for binding ?

Yes, assuming you're talking font name (e.g. arial). I can do that for you if you wish. It's not hard but there are like 3 places you have to touch.

In both cases, I am will to add it and test with php mapscript since I need to use it for a client side tool.

Thanks

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: sdlime
Date: 2007/06/28 - 06:51
Replying to [comment:8 assefa]:

Another point I forgot : how would the save through mapscript work ? In my opinion, It would make sense to save the attribute bindings. Right now the it saves the last values that were using while rendering.

Whoops, forgot to fix the writers to check for a binding. Will add to the todo in the main description.

mapserver-bot commented Apr 3, 2012

Author: sdlime
Date: 2007/06/28 - 06:51
Replying to [comment:8 assefa]:

Another point I forgot : how would the save through mapscript work ? In my opinion, It would make sense to save the attribute bindings. Right now the it saves the last values that were using while rendering.

Whoops, forgot to fix the writers to check for a binding. Will add to the todo in the main description.

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: assefa
Date: 2007/06/28 - 07:06
I think we can add the addBinding (or is it setBinding ??) and removeBinding at the mapscript level as you descibed it. I will add the php methods on both style and label adn do the tests.

as for the Font : yes I meant the font name and yes you can add it :)

I have also locally modified mapfile.c to save the bindings when the map file is written (writeStyle and writeLabel functions). It looks something like :
if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_ANGLE].item)
fprintf(stream, " ANGLE [%s]\n", style->bindings[MS_STYLE_BINDING_ANGLE].item);
else if(style->angle != 0) fprintf(stream, " ANGLE %g\n", style->angle);

It seems to work and I would like to commit if you agree. I will also add the FONT saving when you are done binding the FONT.

Thanks

mapserver-bot commented Apr 3, 2012

Author: assefa
Date: 2007/06/28 - 07:06
I think we can add the addBinding (or is it setBinding ??) and removeBinding at the mapscript level as you descibed it. I will add the php methods on both style and label adn do the tests.

as for the Font : yes I meant the font name and yes you can add it :)

I have also locally modified mapfile.c to save the bindings when the map file is written (writeStyle and writeLabel functions). It looks something like :
if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_ANGLE].item)
fprintf(stream, " ANGLE [%s]\n", style->bindings[MS_STYLE_BINDING_ANGLE].item);
else if(style->angle != 0) fprintf(stream, " ANGLE %g\n", style->angle);

It seems to work and I would like to commit if you agree. I will also add the FONT saving when you are done binding the FONT.

Thanks

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: assefa
Date: 2007/06/29 - 14:25
commited update write functions in mapfile.c to look for a binding 24c458f (r6248)

mapserver-bot commented Apr 3, 2012

Author: assefa
Date: 2007/06/29 - 14:25
commited update write functions in mapfile.c to look for a binding 24c458f (r6248)

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: assefa
Date: 2007/06/29 - 21:28
Added setbinding and removebinding functions in phpmapscript on label and style objects (4ef4db5 (r6251))

mapserver-bot commented Apr 3, 2012

Author: assefa
Date: 2007/06/29 - 21:28
Added setbinding and removebinding functions in phpmapscript on label and style objects (4ef4db5 (r6251))

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: sdlime
Date: 2007/07/11 - 05:36
Added setBinding and removeBinding methods to mapscript (SWIG).

mapserver-bot commented Apr 3, 2012

Author: sdlime
Date: 2007/07/11 - 05:36
Added setBinding and removeBinding methods to mapscript (SWIG).

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: dmorissette
Date: 2007/07/12 - 16:20
FYI I have added missing MS_LABEL_BINDING_FONT and MS_LABEL_BINDING_PRIORITY constants in PHP MapScript in 7188dcd (r6296)

mapserver-bot commented Apr 3, 2012

Author: dmorissette
Date: 2007/07/12 - 16:20
FYI I have added missing MS_LABEL_BINDING_FONT and MS_LABEL_BINDING_PRIORITY constants in PHP MapScript in 7188dcd (r6296)

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: tomkralidis
Date: 2007/09/12 - 15:07

Should this be reassigned to Jeff?

mapserver-bot commented Apr 3, 2012

Author: tomkralidis
Date: 2007/09/12 - 15:07

Should this be reassigned to Jeff?

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: jmckenna
Date: 2008/07/17 - 18:26
Am I correct that for this ticket several existing parameters such as ANGLEITEM were totally removed, causing existing mapfiles with those parameters to break? I assumed both ways would still exist, but the docs would state "deprecated" for the old parameters.
If I am correct, then I will open a new ticket to add the old parameters back into the code.

mapserver-bot commented Apr 3, 2012

Author: jmckenna
Date: 2008/07/17 - 18:26
Am I correct that for this ticket several existing parameters such as ANGLEITEM were totally removed, causing existing mapfiles with those parameters to break? I assumed both ways would still exist, but the docs would state "deprecated" for the old parameters.
If I am correct, then I will open a new ticket to add the old parameters back into the code.

@mapserver-bot

This comment has been minimized.

Show comment
Hide comment
@mapserver-bot

mapserver-bot Apr 3, 2012

Author: jmckenna
Date: 2008/07/17 - 21:10

  • updated mapfile reference for new attribute binding
  • re: removed parameters: I've discussed this with Daniel and Howard on IRC. I have updated the docs accordingly.
  • I have also created ticket#2707 to inquire about some more possible parameters to "bind" to attributes.

mapserver-bot commented Apr 3, 2012

Author: jmckenna
Date: 2008/07/17 - 21:10

  • updated mapfile reference for new attribute binding
  • re: removed parameters: I've discussed this with Daniel and Howard on IRC. I have updated the docs accordingly.
  • I have also created ticket#2707 to inquire about some more possible parameters to "bind" to attributes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment