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

Styles' OFFSET values are saved as ints though they are doubles. #5310

Closed
MaklariAgoston opened this Issue Aug 23, 2016 · 0 comments

Comments

Projects
None yet
3 participants
@MaklariAgoston
Copy link

MaklariAgoston commented Aug 23, 2016

In mapserver.h (row 1006) we can see the styleObj struct has offsetx and offsety. They are double.

mapserver.h

struct styleObj{
...
double offsetx, offsety; /* for shadows, hollow symbols, etc... */
...
}

According to this we can see in mapfile.c (row 2726 and 2736) they are treated as doubles when they are loaded in.

mapfile.c

int loadStyle(styleObj *style)
{
...
case(OFFSET):
if((symbol = getSymbol(2, MS_NUMBER,MS_BINDING)) == -1) return(MS_FAILURE);
if(symbol == MS_NUMBER)
style->offsetx = (double) msyynumber;
else {
...
if(symbol == MS_NUMBER)
style->offsety = (double) msyynumber;
else {
...
}

But in mapfile.c (row 2986) the style is saved by a writeDimension (mapfile.c row 525) function which wait ints on its 4th and 5th operands
that is why the OFFSET value of styleObj losts the precision of double when the map file is saved.

mapfile.c

...

static void writeDimension(FILE *stream, int indent, const char *name, int x, int y, char *bind_x, char *bind_y)
{
writeIndent(stream, ++indent);
if(bind_x) msIO_fprintf(stream, "%s [%s] ", name, bind_x);
else msIO_fprintf(stream, "%s %d ", name, x);
if(bind_y) msIO_fprintf(stream, "[%s]\n", bind_y);
else msIO_fprintf(stream, "%d\n", y);
}

...

void writeStyle(FILE *stream, int indent, styleObj *style)
{
...
writeDimension(stream, indent, "OFFSET", style->offsetx, style->offsety, style->bindings[MS_STYLE_BINDING_OFFSET_X].item, style->bindings[MS_STYLE_BINDING_OFFSET_Y].item);
...
}

The solution for this issue could be anther writeDimension function with 2 double operands.

@szekerest szekerest self-assigned this Aug 23, 2016

geographika added a commit to geographika/mapserver that referenced this issue Nov 30, 2018

sdlime added a commit to sdlime/mapserver that referenced this issue Jan 23, 2019

Updated writeDimension() to take doubles instead of ints (mapserver#5310
) as input. Output pattern follows writeNumber().

sdlime added a commit that referenced this issue Jan 23, 2019

Merge pull request #5738 from sdlime/issue-5310
Updated writeDimension() to take doubles instead of ints (#5310) as i…

@sdlime sdlime closed this Jan 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.