Skip to content

Commit

Permalink
Merge branch 'branch-6-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Nov 9, 2012
2 parents b8e6e0c + 1da915d commit bb924e4
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 48 deletions.
3 changes: 3 additions & 0 deletions HISTORY.TXT
@@ -1,3 +1,4 @@

MapServer Revision History
==========================

Expand All @@ -14,6 +15,8 @@ For a complete change history, please see the Git log comments.
Current Version (git master, 6.3-dev, future 6.4):
--------------------------------------------------

- Fix WFS GetFeature result bounds are not written in requested projection (#4494)

- Fixed wrong size in LegendURL of root layer (#4441)

- Fixed wms_style_name in GetMap requests (#4439)
Expand Down
2 changes: 1 addition & 1 deletion mapdraw.c
Expand Up @@ -2274,7 +2274,7 @@ int msDrawLabel(mapObj *map, imageObj *image, pointObj labelPnt, char *string, l

if(!string) return MS_SUCCESS; /* not an error, just don't need to do anything more */
if(strlen(string) == 0) return MS_SUCCESS; /* not an error, just don't need to do anything more */

if(label->status == MS_OFF) return(MS_SUCCESS); /* not an error */


if(label->type == MS_TRUETYPE) {
Expand Down
11 changes: 10 additions & 1 deletion maplayer.c
Expand Up @@ -204,7 +204,7 @@ int msLayerGetShape(layerObj *layer, shapeObj *shape, resultObj *record)
*/
void msLayerClose(layerObj *layer)
{
int i,j;
int i,j,k;

/* no need for items once the layer is closed */
msLayerFreeItemInfo(layer);
Expand All @@ -223,6 +223,10 @@ void msLayerClose(layerObj *layer)
freeExpressionTokens(&(layer->class[i]->text));
for(j=0; j<layer->class[i]->numstyles; j++)
freeExpressionTokens(&(layer->class[i]->styles[j]->_geomtransform));
for(k=0; k<layer->class[i]->numlabels; k++) {
freeExpressionTokens(&(layer->class[i]->labels[k]->expression));
freeExpressionTokens(&(layer->class[i]->labels[k]->text));
}
}

if (layer->vtable) {
Expand Down Expand Up @@ -478,6 +482,11 @@ int msLayerWhichItems(layerObj *layer, int get_all, char *metadata)
*/

/* layer level counts */
layer->classitemindex = -1;
layer->filteritemindex = -1;
layer->styleitemindex = -1;
layer->labelitemindex = -1;

if(layer->classitem) nt++;
if(layer->filteritem) nt++;
if(layer->styleitem && strcasecmp(layer->styleitem, "AUTO") != 0) nt++;
Expand Down
35 changes: 23 additions & 12 deletions mapmssql2008.c
Expand Up @@ -824,22 +824,22 @@ static int prepare_database(layerObj *layer, rectObj rect, char **query_string)
char buffer[1000];

if (layerinfo->geometry_format == MSSQLGEOMETRY_NATIVE)
snprintf(buffer, sizeof(buffer), "%s,convert(varchar(36), %s)", layerinfo->geom_column, layerinfo->urid_name);
snprintf(buffer, sizeof(buffer), "[%s],convert(varchar(36), [%s])", layerinfo->geom_column, layerinfo->urid_name);
else
snprintf(buffer, sizeof(buffer), "%s.STAsBinary(),convert(varchar(36), %s)", layerinfo->geom_column, layerinfo->urid_name);
snprintf(buffer, sizeof(buffer), "[%s].STAsBinary(),convert(varchar(36), [%s])", layerinfo->geom_column, layerinfo->urid_name);

columns_wanted = msStrdup(buffer);
} else {
char buffer[10000] = "";

for(t = 0; t < layer->numitems; t++) {
snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "convert(varchar(max), %s),", layer->items[t]);
snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "convert(varchar(max), [%s]),", layer->items[t]);
}

if (layerinfo->geometry_format == MSSQLGEOMETRY_NATIVE)
snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "%s,convert(varchar(36), %s)", layerinfo->geom_column, layerinfo->urid_name);
snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "[%s],convert(varchar(36), [%s])", layerinfo->geom_column, layerinfo->urid_name);
else
snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "%s.STAsBinary(),convert(varchar(36), %s)", layerinfo->geom_column, layerinfo->urid_name);
snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "[%s].STAsBinary(),convert(varchar(36), [%s])", layerinfo->geom_column, layerinfo->urid_name);

columns_wanted = msStrdup(buffer);
}
Expand Down Expand Up @@ -1820,9 +1820,8 @@ int msMSSQL2008LayerGetShape(layerObj *layer, shapeObj *shape, resultObj *record
int msMSSQL2008LayerGetItems(layerObj *layer)
{
msMSSQL2008LayerInfo *layerinfo;
char *geom_column_name = 0;
char sql[1000];
int t;
char *sql = NULL;
int t, sqlSize;
char found_geom = 0;
int item_num;
SQLSMALLINT cols = 0;
Expand All @@ -1846,14 +1845,18 @@ int msMSSQL2008LayerGetItems(layerObj *layer)
return MS_FAILURE;
}

snprintf(sql, sizeof(sql), "SELECT top 0 * FROM %s", layerinfo->geom_table);
sqlSize = strlen(layerinfo->geom_table) + 30;
sql = msSmallMalloc(sizeof(char *) * sqlSize);

if (!executeSQL(layerinfo->conn, sql)) {
msFree(geom_column_name);
snprintf(sql, sqlSize, "SELECT top 0 * FROM %s", layerinfo->geom_table);

if (!executeSQL(layerinfo->conn, sql)) {
msFree(sql);
return MS_FAILURE;
}

msFree(sql);

SQLNumResultCols (layerinfo->conn->hstmt, &cols);

layer->numitems = cols - 1; /* dont include the geometry column */
Expand Down Expand Up @@ -1998,7 +2001,9 @@ static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, c
char *pos_opt, *pos_scn, *tmp, *pos_srid, *pos_urid, *pos_geomtype, *pos_geomtype2, *pos_indexHint, *data;
int slength;

data = layer->data;
data = msStrdup(layer->data);
/* replace tabs with spaces */
msReplaceChar(data, '\t', ' ');

/* given a string of the from 'geom from ctivalues' or 'geom from () as foo'
* return geom_column_name as 'geom'
Expand Down Expand Up @@ -2029,6 +2034,7 @@ static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, c
if(!slength) {
msSetError(MS_QUERYERR, DATA_ERROR_MESSAGE, "msMSSQL2008LayerParseData()", "Error parsing MSSQL2008 data variable: You specified 'using SRID=#' but didnt have any numbers!<br><br>\n\nMore Help:<br><br>\n\n", data);

msFree(data);
return MS_FAILURE;
} else {
*user_srid = (char *) msSmallMalloc(slength + 1);
Expand Down Expand Up @@ -2059,6 +2065,7 @@ static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, c
if(!pos_scn) {
msSetError(MS_QUERYERR, DATA_ERROR_MESSAGE, "msMSSQL2008LayerParseData()", "Error parsing MSSQL2008 data variable. Must contain 'geometry_column from table_name' or 'geom from (subselect) as foo' (couldn't find ' from '). More help: <br><br>\n\n", data);

msFree(data);
return MS_FAILURE;
}

Expand All @@ -2073,6 +2080,7 @@ static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, c
++pos_geomtype2;
if (*pos_geomtype2 != ')' || pos_geomtype2 == pos_geomtype) {
msSetError(MS_QUERYERR, DATA_ERROR_MESSAGE, "msMSSQL2008LayerParseData()", "Error parsing MSSQL2008 data variable. Invalid syntax near geometry column type.", data);
msFree(data);
return MS_FAILURE;
}

Expand All @@ -2095,6 +2103,7 @@ static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, c
if(strlen(*table_name) < 1 || strlen(*geom_column_name) < 1) {
msSetError(MS_QUERYERR, DATA_ERROR_MESSAGE, "msMSSQL2008LayerParseData()", "Error parsing MSSQL2008 data variable. Must contain 'geometry_column from table_name' or 'geom from (subselect) as foo' (couldnt find a geometry_column or table/subselect). More help: <br><br>\n\n", data);

msFree(data);
return MS_FAILURE;
}

Expand All @@ -2103,6 +2112,7 @@ static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, c
msSetError(MS_QUERYERR, DATA_ERROR_MESSAGE, "msMSSQL2008LayerParseData()", "No primary key defined for table, or primary key contains more that one column\n\n",
*table_name);

msFree(data);
return MS_FAILURE;
}
}
Expand All @@ -2111,6 +2121,7 @@ static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, c
msDebug("msMSSQL2008LayerParseData: unique column = %s, srid='%s', geom_column_name = %s, table_name=%s\n", *urid_name, *user_srid, *geom_column_name, *table_name);
}

msFree(data);
return MS_SUCCESS;
}

Expand Down
21 changes: 15 additions & 6 deletions mapogr.cpp
Expand Up @@ -2553,21 +2553,28 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
const char *pszFontName = OGR_ST_GetParamStr(hLabelStyle,
OGRSTLabelFontName,
&bIsNull);
const char *pszName = CPLSPrintf("%s%s%s", pszFontName, pszBold, pszItalic);
/* replace spaces with hyphens to allow mapping to a valid hashtable entry*/
char* pszFontNameEscaped = NULL;
if (pszFontName != NULL) {
pszFontNameEscaped = strdup(pszFontName);
msReplaceChar(pszFontNameEscaped, ' ', '-');
}

const char *pszName = CPLSPrintf("%s%s%s", pszFontNameEscaped, pszBold, pszItalic);
bool bFont = true;

if (pszFontName != NULL && !bIsNull && pszFontName[0] != '\0') {
if (pszFontNameEscaped != NULL && !bIsNull && pszFontNameEscaped[0] != '\0') {
if (msLookupHashTable(&(map->fontset.fonts), (char*)pszName) != NULL) {
c->labels[0]->type = MS_TRUETYPE;
c->labels[0]->font = msStrdup(pszName);
if (layer->debug >= MS_DEBUGLEVEL_VVV)
msDebug("** Using '%s' TTF font **\n", pszName);
} else if ( (strcmp(pszFontName,pszName) != 0) &&
msLookupHashTable(&(map->fontset.fonts), (char*)pszFontName) != NULL) {
} else if ( (strcmp(pszFontNameEscaped,pszName) != 0) &&
msLookupHashTable(&(map->fontset.fonts), (char*)pszFontNameEscaped) != NULL) {
c->labels[0]->type = MS_TRUETYPE;
c->labels[0]->font = msStrdup(pszFontName);
c->labels[0]->font = msStrdup(pszFontNameEscaped);
if (layer->debug >= MS_DEBUGLEVEL_VVV)
msDebug("** Using '%s' TTF font **\n", pszFontName);
msDebug("** Using '%s' TTF font **\n", pszFontNameEscaped);
} else if (msLookupHashTable(&(map->fontset.fonts),"default") != NULL) {
c->labels[0]->type = MS_TRUETYPE;
c->labels[0]->font = msStrdup("default");
Expand All @@ -2577,6 +2584,8 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
bFont = false;
}

msFree(pszFontNameEscaped);

if (!bFont) {
c->labels[0]->type = MS_BITMAP;
c->labels[0]->size = MS_MEDIUM;
Expand Down
5 changes: 2 additions & 3 deletions maporaclespatial.c
Expand Up @@ -2148,9 +2148,6 @@ int msOracleSpatialLayerNextShape( layerObj *layer, shapeObj *shape )
do {
/* is buffer empty? */
if (sthand->row >= sthand->rows_fetched) {
if (sthand->row_num >= sthand->rows_count)
return MS_DONE;

/* fetch more */
success = TRY( hand, OCIStmtFetch2( sthand->stmthp, hand->errhp, (ub4)ARRAY_SIZE, (ub2)OCI_FETCH_NEXT, (sb4)0, (ub4)OCI_DEFAULT ) )
&& TRY( hand, OCIAttrGet( (dvoid *)sthand->stmthp, (ub4)OCI_HTYPE_STMT, (dvoid *)&sthand->rows_fetched, (ub4 *)0, (ub4)OCI_ATTR_ROWS_FETCHED, hand->errhp ) )
Expand All @@ -2159,6 +2156,8 @@ int msOracleSpatialLayerNextShape( layerObj *layer, shapeObj *shape )
if(layer->debug >= 4 )
msDebug("msOracleSpatialLayerNextShape on layer %p, Fetched %d more rows (%d total)\n", layer, sthand->rows_fetched, sthand->rows_count);

if (sthand->row_num >= sthand->rows_count)
return MS_DONE;

if (!success || sthand->rows_fetched == 0)
return MS_DONE;
Expand Down
27 changes: 27 additions & 0 deletions mapscript/swiginc/label.i
Expand Up @@ -93,6 +93,33 @@

return MS_SUCCESS;
}

int setExpression(char *expression)
{
if (!expression || strlen(expression) == 0) {
freeExpression(&self->expression);
return MS_SUCCESS;
}
else return msLoadExpressionString(&self->expression, expression);
}

%newobject getExpressionString;
char *getExpressionString() {
return msGetExpressionString(&(self->expression));
}

int setText(char *text) {
if (!text || strlen(text) == 0) {
freeExpression(&self->text);
return MS_SUCCESS;
}
else return msLoadExpressionString(&self->text, text);
}

%newobject getTextString;
char *getTextString() {
return msGetExpressionString(&(self->text));
}

%newobject getStyle;
styleObj *getStyle(int i) {
Expand Down
6 changes: 6 additions & 0 deletions mapserv.c
Expand Up @@ -286,5 +286,11 @@ int main(int argc, char *argv[])
(execstarttime.tv_sec+execstarttime.tv_usec/1.0e6) );
}
msCleanup(0);

#ifdef _WIN32
/* flush pending writes to stdout */
fflush(stdout);
#endif

exit( 0 );
}
7 changes: 6 additions & 1 deletion mapsymbol.c
Expand Up @@ -44,6 +44,8 @@ extern char *msyystring_buffer;
extern int msyylineno;
extern FILE *msyyin;

extern int msyystate;

static const unsigned char PNGsig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; /* 89 50 4E 47 0D 0A 1A 0A hex */
static const unsigned char JPEGsig[3] = {255, 216, 255}; /* FF D8 FF hex */

Expand Down Expand Up @@ -549,6 +551,9 @@ int loadSymbolSet(symbolSetObj *symbolset, mapObj *map)

pszSymbolPath = msGetPath(szPath);

msyystate = MS_TOKENIZE_FILE; /* restore lexer state to INITIAL, and do return comments */
msyylex(); /* sets things up, but doesn't process any tokens */

msyylineno = 0; /* reset line counter */
msyyrestart(msyyin); /* flush the scanner - there's a better way but this works for now */

Expand Down Expand Up @@ -651,7 +656,7 @@ int msGetMarkerSize(symbolSetObj *symbolset, styleObj *style, double *width, dou
*width = MS_MAX(*width, symbol->pixmap_buffer->width);
*height = MS_MAX(*height, symbol->pixmap_buffer->height);
} else {
*width = MS_MAX(*width, ((size/symbol->pixmap_buffer->height) * symbol->pixmap_buffer->width));
*width = MS_MAX(*width, (((double)size/(double)symbol->pixmap_buffer->height) * symbol->pixmap_buffer->width));
*height = MS_MAX(*height, size);
}
break;
Expand Down
22 changes: 11 additions & 11 deletions mapuvraster.c
Expand Up @@ -66,8 +66,6 @@ typedef struct {

int refcount;

rectObj which_rect;

/* query bound in force
shapeObj *searchshape;*/

Expand Down Expand Up @@ -332,11 +330,11 @@ static char **msUVRASTERGetValues(layerObj *layer, float *u, float *v)
}

int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)

{
uvRasterLayerInfo *uvlinfo = (uvRasterLayerInfo *) layer->layerinfo;
imageObj *image_tmp;
mapObj map_tmp;
double map_cellsize;
unsigned int spacing;
int width, height, u_src_off, v_src_off, i, x, y;
char **alteredProcessing = NULL;
Expand All @@ -361,18 +359,20 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
return MS_FAILURE;
}
/* -------------------------------------------------------------------- */
/* Determine desired spacing. Default to 30 if not otherwise set */
/* Determine desired spacing. Default to 32 if not otherwise set */
/* -------------------------------------------------------------------- */
spacing = 30;
spacing = 32;
if( CSLFetchNameValue( layer->processing, "UV_SPACING" ) != NULL ) {
spacing =
atoi(CSLFetchNameValue( layer->processing, "UV_SPACING" ));
}

width = (int)ceil(layer->map->width/spacing);
height = (int)ceil(layer->map->height/spacing);
map_tmp.cellsize = layer->map->cellsize*spacing;

map_cellsize = MS_MAX(MS_CELLSIZE(rect.minx, rect.maxx,layer->map->width),
MS_CELLSIZE(rect.miny,rect.maxy,layer->map->height));
map_tmp.cellsize = map_cellsize*spacing;

if (layer->debug)
msDebug("msUVRASTERLayerWhichShapes(): width: %d, height: %d, cellsize: %g\n",
width, height, map_tmp.cellsize);
Expand All @@ -391,16 +391,17 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
map_tmp.outputformat->renderer = MS_RENDER_WITH_RAWDATA;
map_tmp.outputformat->imagemode = MS_IMAGEMODE_FLOAT32;

map_tmp.configoptions = layer->map->configoptions;
map_tmp.mappath = layer->map->mappath;
map_tmp.shapepath = layer->map->shapepath;
map_tmp.extent.minx = layer->map->extent.minx-(0.5*layer->map->cellsize)+(0.5*map_tmp.cellsize);
map_tmp.extent.miny = layer->map->extent.miny-(0.5*layer->map->cellsize)+(0.5*map_tmp.cellsize);
map_tmp.extent.minx = rect.minx-(0.5*map_cellsize)+(0.5*map_tmp.cellsize);
map_tmp.extent.miny = rect.miny-(0.5*map_cellsize)+(0.5*map_tmp.cellsize);
map_tmp.extent.maxx = map_tmp.extent.minx+((width-1)*map_tmp.cellsize);
map_tmp.extent.maxy = map_tmp.extent.miny+((height-1)*map_tmp.cellsize);
map_tmp.gt.rotation_angle = 0.0;

msInitProjection(&map_tmp.projection);
msCopyProjection(&map_tmp.projection, &layer->map->projection);
msCopyProjection(&map_tmp.projection, &layer->projection);

if (layer->debug == 5)
msDebug("msUVRASTERLayerWhichShapes(): extent: %g %d %g %g\n",
Expand Down Expand Up @@ -484,7 +485,6 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)

msFreeImage(image_tmp); /* we do not need the imageObj anymore */

uvlinfo->which_rect = map_tmp.extent;
uvlinfo->next_shape = 0;

return MS_SUCCESS;
Expand Down

0 comments on commit bb924e4

Please sign in to comment.