Permalink
Browse files

Merge pull request #5489 from theduckylittle/feature/offset-scalebar-…

…position

Add an offset to the scalebar
  • Loading branch information...
jmckenna committed Nov 13, 2017
2 parents f776436 + 27b66bc commit 67f4dbb60be32ea705f052d4b735208542c4cc22
View
@@ -5536,6 +5536,8 @@ void initScalebar(scalebarObj *scalebar)
scalebar->interlace = MS_NOOVERRIDE;
scalebar->postlabelcache = MS_FALSE; /* draw with labels */
scalebar->align = MS_ALIGN_CENTER;
scalebar->offsetx = 0;
scalebar->offsety = 0;
}
void freeScalebar(scalebarObj *scalebar)
@@ -5603,6 +5605,10 @@ int loadScalebar(scalebarObj *scalebar)
case(UNITS):
if((scalebar->units = getSymbol(6, MS_INCHES,MS_FEET,MS_MILES,MS_METERS,MS_KILOMETERS,MS_NAUTICALMILES)) == -1) return(-1);
break;
case(OFFSET):
if(getInteger(&(scalebar->offsetx)) == -1) return(-1);
if(getInteger(&(scalebar->offsety)) == -1) return(-1);
break;
default:
if(strlen(msyystring_buffer) > 0) {
msSetError(MS_IDENTERR, "Parsing error near (%s):(line %d)", "loadScalebar()", msyystring_buffer, msyylineno);
View
@@ -428,28 +428,28 @@ int msEmbedScalebar(mapObj *map, imageObj *img)
switch(map->scalebar.position) {
case(MS_LL):
point.x = MS_NINT(embededSymbol->pixmap_buffer->width/2.0);
point.y = map->height - MS_NINT(embededSymbol->pixmap_buffer->height/2.0);
point.x = MS_NINT(embededSymbol->pixmap_buffer->width/2.0) + map->scalebar.offsetx;
point.y = map->height - MS_NINT(embededSymbol->pixmap_buffer->height/2.0) - map->scalebar.offsety;
break;
case(MS_LR):
point.x = map->width - MS_NINT(embededSymbol->pixmap_buffer->width/2.0);
point.y = map->height - MS_NINT(embededSymbol->pixmap_buffer->height/2.0);
point.x = map->width - MS_NINT(embededSymbol->pixmap_buffer->width/2.0) - map->scalebar.offsetx;
point.y = map->height - MS_NINT(embededSymbol->pixmap_buffer->height/2.0) - map->scalebar.offsety;
break;
case(MS_LC):
point.x = MS_NINT(map->width/2.0);
point.y = map->height - MS_NINT(embededSymbol->pixmap_buffer->height/2.0);
point.x = MS_NINT(map->width/2.0) + map->scalebar.offsetx;
point.y = map->height - MS_NINT(embededSymbol->pixmap_buffer->height/2.0) - map->scalebar.offsety;
break;
case(MS_UR):
point.x = map->width - MS_NINT(embededSymbol->pixmap_buffer->width/2.0);
point.y = MS_NINT(embededSymbol->pixmap_buffer->height/2.0);
point.x = map->width - MS_NINT(embededSymbol->pixmap_buffer->width/2.0) - map->scalebar.offsetx;
point.y = MS_NINT(embededSymbol->pixmap_buffer->height/2.0) + map->scalebar.offsety;
break;
case(MS_UL):
point.x = MS_NINT(embededSymbol->pixmap_buffer->width/2.0);
point.y = MS_NINT(embededSymbol->pixmap_buffer->height/2.0);
point.x = MS_NINT(embededSymbol->pixmap_buffer->width/2.0) + map->scalebar.offsetx;
point.y = MS_NINT(embededSymbol->pixmap_buffer->height/2.0) + map->scalebar.offsety;
break;
case(MS_UC):
point.x = MS_NINT(map->width/2.0);
point.y = MS_NINT(embededSymbol->pixmap_buffer->height/2.0);
point.x = MS_NINT(map->width/2.0) + map->scalebar.offsetx;
point.y = MS_NINT(embededSymbol->pixmap_buffer->height/2.0) + map->scalebar.offsety;
break;
}
View
@@ -1422,6 +1422,8 @@ typedef struct labelObj labelObj;
#endif /* not SWIG */
int postlabelcache;
int align;
int offsetx;
int offsety;
} scalebarObj;
/************************************************************************/
@@ -0,0 +1,42 @@
# RUN_PARMS: embed_sb_rgba_offset.png [SHP2IMG] -m [MAPFILE] -i png -o [RESULT]
# RUN_PARMS: embed_sb_rgba_offset.cairo.png [SHP2IMG] -m [MAPFILE] -i cairopng -o [RESULT]
#
#
# Test embedded scalebar with an offset.
#
# REQUIRES: OUTPUT=PNG
#
MAP
EXTENT -180 -90 180 90
SIZE 160 40
IMAGECOLOR 0 0 0
fontset "../misc/fonts.lst"
TRANSPARENT ON
IMAGETYPE png
SCALEBAR
TRANSPARENT OFF
LABEL
COLOR 0 0 0
size 9
type truetype
font "default"
END
SIZE 150 3
COLOR 0 0 0
BACKGROUNDCOLOR 255 255 255
OUTLINECOLOR 0 0 0
UNITS kilometers
INTERVALS 3
STATUS EMBED
OFFSET
5 5
END
END
END
Binary file not shown.
Binary file not shown.

0 comments on commit 67f4dbb

Please sign in to comment.