Permalink
Browse files

Fix SLD PerpendicularOffset for lines and labels (#4801)

also use #defines instead of 99/-99 for label offsets
  • Loading branch information...
1 parent be590fa commit 1d8b68afc9b41ba5a76acc4e43c48eb80d224dbb @tbonfort tbonfort committed Oct 28, 2013
Showing with 12 additions and 6 deletions.
  1. +3 −2 mapogcsld.c
  2. +3 −3 mapprimitive.c
  3. +6 −1 mapserver.h
View
@@ -1128,7 +1128,7 @@ int msSLDParseLineSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
psOffset = CPLGetXMLNode(psRoot, "PerpendicularOffset");
if (psOffset && psOffset->psChild && psOffset->psChild->pszValue) {
psLayer->class[nClassId]->styles[iStyle]->offsetx = atoi(psOffset->psChild->pszValue);
- psLayer->class[nClassId]->styles[iStyle]->offsety = psLayer->class[nClassId]->styles[iStyle]->offsetx;
+ psLayer->class[nClassId]->styles[iStyle]->offsety = MS_STYLE_SINGLE_SIDED_OFFSET;
}
}
@@ -3030,7 +3030,7 @@ int ParseTextLinePlacement(CPLXMLNode *psRoot, classObj *psClass)
psOffset = CPLGetXMLNode(psRoot, "PerpendicularOffset");
if (psOffset && psOffset->psChild && psOffset->psChild->pszValue) {
psLabelObj->offsetx = atoi(psOffset->psChild->pszValue);
- psLabelObj->offsety = atoi(psOffset->psChild->pszValue);
+ psLabelObj->offsety = MS_LABEL_PERPENDICULAR_OFFSET;
/*if there is a PerpendicularOffset, we will assume that the
best setting for mapserver would be to use angle=0 and the
@@ -3039,6 +3039,7 @@ int ParseTextLinePlacement(CPLXMLNode *psRoot, classObj *psClass)
set the angles if the parameter is not set*/
if (!psAligned) {
psLabelObj->anglemode = MS_NONE;
+ psLabelObj->offsety = psLabelObj->offsetx;
}
}
View
@@ -1754,14 +1754,14 @@ labelPathObj** msPolylineLabelPath(mapObj *map, imageObj *img,shapeObj *p, int m
labelpaths = (labelPathObj **) msSmallMalloc(sizeof(labelPathObj *) * labelpaths_size);
(*regular_lines) = (int *) msSmallMalloc(sizeof(int) * regular_lines_size);
- if(label->offsetx != 0 && (label->offsety == -99 || label->offsety == 99)) {
+ if(label->offsetx != 0 && IS_PERPENDICULAR_OFFSET(label->offsety)) {
double offset;
if(label->offsetx > 0) {
offset = label->offsetx + label->size/2;
} else {
offset = label->offsetx - label->size/2;
}
- if(label->offsety == 99 && p->numlines>0 && p->line[0].numpoints > 0) {
+ if(label->offsety == MS_LABEL_PERPENDICULAR_TOP_OFFSET && p->numlines>0 && p->line[0].numpoints > 0) {
/* is the line mostly left-to-right or right-to-left ?
* FIXME this should be done line by line, by stepping through shape->lines, however
* the OffsetPolyline function works on shapeObjs, not lineObjs
@@ -1799,7 +1799,7 @@ labelPathObj** msPolylineLabelPath(mapObj *map, imageObj *img,shapeObj *p, int m
/* set the number of paths in the array */
*numpaths = labelpaths_index;
*num_regular_lines = regular_lines_index;
- if(label->offsety == -99 && label->offsetx != 0) {
+ if(IS_PERPENDICULAR_OFFSET(label->offsety) && label->offsetx != 0) {
msFreeShape(p);
msFree(p);
}
View
@@ -946,7 +946,7 @@ extern "C" {
#define MS_STYLE_SINGLE_SIDED_OFFSET -99
#define MS_STYLE_DOUBLE_SIDED_OFFSET -999
-#define IS_PARALLEL_OFFSET(offsety) (offsety == MS_STYLE_SINGLE_SIDED_OFFSET || offsety == MS_STYLE_DOUBLE_SIDED_OFFSET)
+#define IS_PARALLEL_OFFSET(offsety) ((offsety) == MS_STYLE_SINGLE_SIDED_OFFSET || (offsety) == MS_STYLE_DOUBLE_SIDED_OFFSET)
@@ -1061,6 +1061,11 @@ extern "C" {
labelLeaderObj leader;
};
+#define MS_LABEL_PERPENDICULAR_OFFSET -99
+#define MS_LABEL_PERPENDICULAR_TOP_OFFSET 99
+#define IS_PERPENDICULAR_OFFSET(offsety) ((offsety) == MS_LABEL_PERPENDICULAR_OFFSET || (offsety) == MS_LABEL_PERPENDICULAR_TOP_OFFSET)
+
+
/************************************************************************/
/* classObj */
/* */

0 comments on commit 1d8b68a

Please sign in to comment.