# [mapserver-dev] Offset x -99 rendering Problem (and possibly a solution)

Torsten Weber TWeber at traffic-consult.de
Mon Feb 16 03:43:15 EST 2009

```Hi all,

in our application we need to be able to display line objects which in
some case bare the same coordinates used in reverse order.
In our case a travel route (line object) on a street map consists of the
same street (bearing the same coordinates) used in both directions.

We use the offset to mark the affected direction of traffic flow of an event.
If the event affects both directions and the directions are not seperated by
contruction, a geometry will be generated which has coordinates in reversed
order.

The offset calculation in maputils.c checks for equal direction only by
checking the gradient but not for reversed direction, so a point will be lost
and next point is calculated to "nowhere".

We've applied a patch to our local mapserver source which solves this for our
needs. We changed line 1530 to line 1532 in maputils.c from
if(k==k0) continue; /* checking equal direction */
x = (q-q0)/(k0-k);
y = k*x+q;

to
if (k==k0) {
if ((dx<0&&dx0>0)||(dx>0&&dx0<0)) { //reversed??
ret->line[i].numpoints++;
ret->line[i].point=realloc(ret->line[i].point,
sizeof(pointObj)*ret->line[i].numpoints);
ret->line[i].point[idx].x =
p->line[i].point[j-1].x-ox;
ret->line[i].point[idx].y = p->line[i].point[j-1].y-oy;
idx++;
x = p->line[i].point[j-1].x+ox;
y = p->line[i].point[j-1].y+oy;
} else {
continue;
}
} else {
x = (q-q0)/(k0-k);
y = k*x+q;
}

It would be nice, if this can find its way to the next mapserver release.

With regards

Torsten Weber

```