Skip to content

Commit

Permalink
restore mixed positions/anglemode enum (was causing backwards incompa…
Browse files Browse the repository at this point in the history
…tibilities in mapscripts)
  • Loading branch information
tbonfort committed Oct 15, 2013
1 parent 379f263 commit 7399024
Show file tree
Hide file tree
Showing 8 changed files with 1,917 additions and 1,412 deletions.
4 changes: 2 additions & 2 deletions mapdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ int lineLayerDrawShape(mapObj *map, imageObj *image, layerObj *layer, shapeObj *
msPopulateTextSymbolForLabelAndString(&ts,label,annotext,layer->scalefactor,image->resolutionfactor, layer->labelcache);


if (label->anglemode == MS_ANGLEMODE_FOLLOW) { /* bug #1620 implementation */
if (label->anglemode == MS_FOLLOW) { /* bug #1620 implementation */
struct label_follow_result lfr;

if (!layer->labelcache) {
Expand Down Expand Up @@ -2813,7 +2813,7 @@ int msDrawLabelCache(mapObj *map, imageObj *image)
}

/* apply offset and buffer settings */
if(textSymbolPtr->label->anglemode != MS_ANGLEMODE_FOLLOW) {
if(textSymbolPtr->label->anglemode != MS_FOLLOW) {
label_offset_x = textSymbolPtr->label->offsetx * textSymbolPtr->scalefactor;
label_offset_y = textSymbolPtr->label->offsety * textSymbolPtr-> scalefactor;
} else {
Expand Down
8 changes: 3 additions & 5 deletions mapfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ void initLabel(labelObj *label)

label->position = MS_CC;
label->angle = 0;
label->anglemode = MS_ANGLEMODE_NONE;
label->anglemode = MS_NONE;
label->minsize = MS_MINFONTSIZE;
label->maxsize = MS_MAXFONTSIZE;
label->buffer = 0;
Expand Down Expand Up @@ -1844,7 +1844,7 @@ static int loadLabel(labelObj *label)
for(;;) {
switch(msyylex()) {
case(ANGLE):
if((symbol = getSymbol(5, MS_NUMBER,MS_AUTO,MS_ANGLEMODE_AUTO2,MS_ANGLEMODE_FOLLOW,MS_BINDING)) == -1)
if((symbol = getSymbol(5, MS_NUMBER,MS_AUTO,MS_AUTO2,MS_FOLLOW,MS_BINDING)) == -1)
return(-1);

if(symbol == MS_NUMBER)
Expand All @@ -1854,8 +1854,6 @@ static int loadLabel(labelObj *label)
msFree(label->bindings[MS_LABEL_BINDING_ANGLE].item);
label->bindings[MS_LABEL_BINDING_ANGLE].item = msStrdup(msyystring_buffer);
label->numbindings++;
} else if ( symbol == MS_AUTO ) {
label->anglemode = MS_ANGLEMODE_AUTO;
} else {
label->anglemode = symbol;
}
Expand Down Expand Up @@ -2139,7 +2137,7 @@ static void writeLabel(FILE *stream, int indent, labelObj *label)

if(label->numbindings > 0 && label->bindings[MS_LABEL_BINDING_ANGLE].item)
writeAttributeBinding(stream, indent, "ANGLE", &(label->bindings[MS_LABEL_BINDING_ANGLE]));
else writeNumberOrKeyword(stream, indent, "ANGLE", 0, label->angle, label->anglemode, 3, MS_ANGLEMODE_FOLLOW, "FOLLOW", MS_ANGLEMODE_AUTO, "AUTO", MS_ANGLEMODE_AUTO2, "AUTO2");
else writeNumberOrKeyword(stream, indent, "ANGLE", 0, label->angle, label->anglemode, 3, MS_FOLLOW, "FOLLOW", MS_AUTO, "AUTO", MS_AUTO2, "AUTO2");

writeExpression(stream, indent, "EXPRESSION", &(label->expression));

Expand Down
3,287 changes: 1,898 additions & 1,389 deletions maplexer.c

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions maplexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ char path[MS_MAXPATHLEN];

<INITIAL,URL_STRING>annotation { MS_LEXER_RETURN_TOKEN(MS_LAYER_ANNOTATION); }
<INITIAL,URL_STRING>auto { MS_LEXER_RETURN_TOKEN(MS_AUTO); }
<INITIAL,URL_STRING>auto2 { MS_LEXER_RETURN_TOKEN(MS_ANGLEMODE_AUTO2); }
<INITIAL,URL_STRING>auto2 { MS_LEXER_RETURN_TOKEN(MS_AUTO2); }
<INITIAL>bevel { MS_LEXER_RETURN_TOKEN(MS_CJC_BEVEL); }
<INITIAL>bitmap { MS_LEXER_RETURN_TOKEN(MS_BITMAP); }
<INITIAL>butt { MS_LEXER_RETURN_TOKEN(MS_CJC_BUTT); }
Expand All @@ -419,7 +419,7 @@ char path[MS_MAXPATHLEN];
<INITIAL,URL_STRING>embed { MS_LEXER_RETURN_TOKEN(MS_EMBED); }
<INITIAL,URL_STRING>false { MS_LEXER_RETURN_TOKEN(MS_FALSE); }
<INITIAL,URL_STRING>feet { MS_LEXER_RETURN_TOKEN(MS_FEET); }
<INITIAL,URL_STRING>follow { MS_LEXER_RETURN_TOKEN(MS_ANGLEMODE_FOLLOW); }
<INITIAL,URL_STRING>follow { MS_LEXER_RETURN_TOKEN(MS_FOLLOW); }
<INITIAL>giant { MS_LEXER_RETURN_TOKEN(MS_GIANT); }
<INITIAL>hatch { MS_LEXER_RETURN_TOKEN(MS_SYMBOL_HATCH); }
<INITIAL>hilite { MS_LEXER_RETURN_TOKEN(MS_HILITE); }
Expand Down
8 changes: 4 additions & 4 deletions mapogcsld.c
Original file line number Diff line number Diff line change
Expand Up @@ -2669,7 +2669,7 @@ int msSLDParseTextParams(CPLXMLNode *psRoot, layerObj *psLayer,

/*set the angle by default to auto. the angle can be
modified Label Placement #2806*/
psLabelObj->anglemode = MS_ANGLEMODE_AUTO;
psLabelObj->anglemode = MS_AUTO;


/* label */
Expand Down Expand Up @@ -3014,13 +3014,13 @@ int ParseTextLinePlacement(CPLXMLNode *psRoot, classObj *psClass)
/*if there is a line placement, we will assume that the
best setting for mapserver would be for the text to follow
the line #2806*/
psLabelObj->anglemode = MS_ANGLEMODE_FOLLOW;
psLabelObj->anglemode = MS_FOLLOW;

/*sld 1.1.0 has a parameter IsAligned. default value is true*/
psAligned = CPLGetXMLNode(psRoot, "IsAligned");
if (psAligned && psAligned->psChild && psAligned->psChild->pszValue &&
strcasecmp(psAligned->psChild->pszValue, "false") == 0) {
psLabelObj->anglemode = MS_ANGLEMODE_NONE;
psLabelObj->anglemode = MS_NONE;
}
psOffset = CPLGetXMLNode(psRoot, "PerpendicularOffset");
if (psOffset && psOffset->psChild && psOffset->psChild->pszValue) {
Expand All @@ -3033,7 +3033,7 @@ int ParseTextLinePlacement(CPLXMLNode *psRoot, classObj *psClass)
/* since sld 1.1.0 introduces the IsAligned parameter, only
set the angles if the parameter is not set*/
if (!psAligned) {
psLabelObj->anglemode = MS_ANGLEMODE_NONE;
psLabelObj->anglemode = MS_NONE;
}
}

Expand Down
4 changes: 2 additions & 2 deletions mapprimitive.c
Original file line number Diff line number Diff line change
Expand Up @@ -1681,9 +1681,9 @@ int msLineLabelPoint(mapObj *map, lineObj *p, textSymbolObj *ts, struct line_len
}

if(label && ts) {
if(label->anglemode != MS_ANGLEMODE_NONE) {
if(label->anglemode != MS_NONE) {
theta = atan2(p->point[j].x - p->point[j-1].x, p->point[j].y - p->point[j-1].y);
if(label->anglemode == MS_ANGLEMODE_AUTO2) {
if(label->anglemode == MS_AUTO2) {
theta -= MS_PI2;
} else { /* AUTO, FOLLOW */
if(p->point[j-1].x < p->point[j].x) { /* i.e. to the left */
Expand Down
8 changes: 4 additions & 4 deletions mapscript/php/php_mapscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,11 +1023,11 @@ PHP_MINIT_FUNCTION(mapscript)
REGISTER_LONG_CONSTANT("MS_UC", MS_UC, const_flag);
REGISTER_LONG_CONSTANT("MS_LC", MS_LC, const_flag);
REGISTER_LONG_CONSTANT("MS_CC", MS_CC, const_flag);
REGISTER_LONG_CONSTANT("MS_AUTO", MS_ANGLEMODE_AUTO, const_flag);
REGISTER_LONG_CONSTANT("MS_AUTO", MS_AUTO, const_flag);
REGISTER_LONG_CONSTANT("MS_XY", MS_XY, const_flag);
REGISTER_LONG_CONSTANT("MS_FOLLOW", MS_ANGLEMODE_FOLLOW, const_flag);
REGISTER_LONG_CONSTANT("MS_AUTO2", MS_ANGLEMODE_AUTO2, const_flag);
REGISTER_LONG_CONSTANT("MS_NONE", MS_ANGLEMODE_NONE, const_flag);
REGISTER_LONG_CONSTANT("MS_FOLLOW", MS_FOLLOW, const_flag);
REGISTER_LONG_CONSTANT("MS_AUTO2", MS_AUTO2, const_flag);
REGISTER_LONG_CONSTANT("MS_NONE", MS_NONE, const_flag);

/* alignment constants*/
REGISTER_LONG_CONSTANT("MS_ALIGN_LEFT", MS_ALIGN_LEFT, const_flag);
Expand Down
6 changes: 2 additions & 4 deletions mapserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,7 @@ extern "C" {
enum MS_FONT_TYPE {MS_TRUETYPE, MS_BITMAP};

#define MS_POSITIONS_LENGTH 14
enum MS_POSITIONS_ENUM {MS_UL=101, MS_LR, MS_UR, MS_LL, MS_CR, MS_CL, MS_UC, MS_LC, MS_CC, MS_AUTO, MS_XY}; /* Added MS_FOLLOW for bug #1620 implementation. */

enum MS_LABEL_ANGLEMODE{MS_ANGLEMODE_NONE,MS_ANGLEMODE_AUTO,MS_ANGLEMODE_AUTO2,MS_ANGLEMODE_FOLLOW};
enum MS_POSITIONS_ENUM {MS_UL=101, MS_LR, MS_UR, MS_LL, MS_CR, MS_CL, MS_UC, MS_LC, MS_CC, MS_AUTO, MS_XY, MS_NONE, MS_AUTO2,MS_FOLLOW};
#define MS_TINY 5
#define MS_SMALL 7
#define MS_MEDIUM 10
Expand Down Expand Up @@ -1021,7 +1019,7 @@ extern "C" {
int offsetx, offsety;

double angle;
enum MS_LABEL_ANGLEMODE anglemode;
enum MS_POSITIONS_ENUM anglemode;

int buffer; /* space to reserve around a label */

Expand Down

0 comments on commit 7399024

Please sign in to comment.