[mapserver-dev] Pull Request #5712

Shubham Sharma klusbn at gmail.com
Fri Nov 30 05:34:09 PST 2018


Pull Request #5712 Follow Up
Hello, guys in the last email I forgot to mention that what my PR actually
does also link to the PR: https://github.com/mapserver/mapserver/pull/5712
My PR solves the issue
#5310
Styles' OFFSET values are saved as ints though they are doubles.

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);
...
}

And in my PR I have presented a possible solution to this.

Thank You

On Tue, Nov 27, 2018 at 6:55 AM Shubham Sharma <klusbn at gmail.com> wrote:

> Hi I am Shubham
>
> A student in Google code-in working with osgeo organisation and have
> created the pull request #5712 as a part of a task  please review it as
> soon as possible so that I can submit my task.
>
> Thank you
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20181130/006acde2/attachment.html>


More information about the mapserver-dev mailing list