Skip to content

Commit

Permalink
Merge branch 'branch-6-2' of https://github.com/mapserver/mapserver i…
Browse files Browse the repository at this point in the history
…nto intramaps

Conflicts:
	mapfile.c
  • Loading branch information
szekerest committed Aug 21, 2013
2 parents 4e84e07 + c4a70d7 commit 6199608
Show file tree
Hide file tree
Showing 18 changed files with 207 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,7 @@ before_install:
- git submodule update --init --recursive
- sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
- sudo apt-get update -qq
- sudo apt-get install -qq colordiff postgis libpq-dev libpng12-dev libjpeg-dev libgif-dev libgeos-dev libgd2-noxpm-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal1-dev libproj-dev libxml2-dev php5-dev
- sudo apt-get install -qq colordiff postgis postgresql-9.1-postgis-2.0-scripts libpq-dev libpng12-dev libjpeg-dev libgif-dev libgeos-dev libgd2-noxpm-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal1-dev libproj-dev libxml2-dev php5-dev
- cd msautotest
- ./create_postgis_test_data.sh
- cd ..
Expand Down
14 changes: 12 additions & 2 deletions mapfile.c
Expand Up @@ -650,7 +650,17 @@ static void writeColor(FILE *stream, int indent, const char *name, colorObj *def
#if ALPHACOLOR_ENABLED
msIO_fprintf(stream, "%s %d %d %d\n", name, color->red, color->green, color->blue, color->alpha);
#else
msIO_fprintf(stream, "%s %d %d %d\n", name, color->red, color->green, color->blue);
if(color->alpha != 255) {
char buffer[9];
sprintf(buffer, "%02x", color->red);
sprintf(buffer+2, "%02x", color->green);
sprintf(buffer+4, "%02x", color->blue);
sprintf(buffer+6, "%02x", color->alpha);
*(buffer+8) = 0;
msIO_fprintf(stream, "%s \"#%s\"\n", name, buffer);
} else {
msIO_fprintf(stream, "%s %d %d %d\n", name, color->red, color->green, color->blue);
}
#endif
}

Expand Down Expand Up @@ -2129,7 +2139,7 @@ static void writeLabel(FILE *stream, int indent, labelObj *label)
else writeNumber(stream, indent, "SIZE", -1, label->size);
}

writeKeyword(stream, indent, "ALIGN", label->align, MS_ALIGN_CENTER, "CENTER", MS_ALIGN_RIGHT, "RIGHT");
writeKeyword(stream, indent, "ALIGN", label->align, 2, MS_ALIGN_CENTER, "CENTER", MS_ALIGN_RIGHT, "RIGHT");
writeNumber(stream, indent, "BUFFER", 0, label->buffer);

if(label->numbindings > 0 && label->bindings[MS_LABEL_BINDING_COLOR].item)
Expand Down
7 changes: 5 additions & 2 deletions mapio.c
Expand Up @@ -809,10 +809,13 @@ char *msIO_stripStdoutBufferContentType()
}

/* -------------------------------------------------------------------- */
/* Copy out content type. */
/* Copy out content type. Note we go against the coding guidelines */
/* here and use strncpy() instead of strlcpy() as the source */
/* buffer may not be NULL terminated - strlcpy() requires NULL */
/* terminated sources (see issue #4672). */
/* -------------------------------------------------------------------- */
content_type = (char *) malloc(end_of_ct-14+2);
strlcpy( content_type, (const char *) buf->data + 14, end_of_ct - 14 + 2);
strncpy( content_type, (const char *) buf->data + 14, end_of_ct - 14 + 2);
content_type[end_of_ct-14+1] = '\0';

/* -------------------------------------------------------------------- */
Expand Down
10 changes: 5 additions & 5 deletions mapogcsld.c
Expand Up @@ -613,20 +613,20 @@ layerObj *msSLDParseSLD(mapObj *map, char *psSLDXML, int *pnLayers)
}


int _msSLDParseSizeParameter(CPLXMLNode *psSize)
double _msSLDParseSizeParameter(CPLXMLNode *psSize)
{
int nSize = 0;
double dSize = 0;
CPLXMLNode *psLiteral = NULL;

if (psSize) {
psLiteral = CPLGetXMLNode(psSize, "Literal");
if (psLiteral && psLiteral->psChild && psLiteral->psChild->pszValue)
nSize = atof(psLiteral->psChild->pszValue);
dSize = atof(psLiteral->psChild->pszValue);
else if (psSize->psChild && psSize->psChild->pszValue)
nSize = atof(psSize->psChild->pszValue);
dSize = atof(psSize->psChild->pszValue);
}

return nSize;
return dSize;
}

/************************************************************************/
Expand Down
3 changes: 2 additions & 1 deletion mapows.c
Expand Up @@ -95,7 +95,8 @@ static int msOWSPreParseRequest(cgiRequestObj *request,
owsRequestObj *ows_request)
{
/* decide if KVP or XML */
if (request->type == MS_GET_REQUEST || (request->type == MS_POST_REQUEST && strcmp(request->contenttype, "application/x-www-form-urlencoded")==0)) {
if (request->type == MS_GET_REQUEST || (request->type == MS_POST_REQUEST
&& request->contenttype && strncmp(request->contenttype, "application/x-www-form-urlencoded", strlen("application/x-www-form-urlencoded")) == 0)) {
int i;
/* parse KVP parameters service, version and request */
for (i = 0; i < request->NumParams; ++i) {
Expand Down
4 changes: 3 additions & 1 deletion maprendering.c
Expand Up @@ -833,13 +833,15 @@ int msDrawMarkerSymbol(symbolSetObj *symbolset,imageObj *image, pointObj *p, sty
break;
}

s.style = style;
computeSymbolStyle(&s,style,symbol,scalefactor,image->resolutionfactor);
s.style = style;
if (!s.color && !s.outlinecolor && symbol->type != MS_SYMBOL_PIXMAP &&
symbol->type != MS_SYMBOL_SVG) {
return MS_SUCCESS; // nothing to do if no color, except for pixmap symbols
}
if(s.scale == 0) {
return MS_SUCCESS;
}



Expand Down
2 changes: 1 addition & 1 deletion mapscript/php/php_mapscript.c
Expand Up @@ -169,7 +169,7 @@ PHP_FUNCTION(ms_newMapObjFromString)
map = mapObj_newFromString(string, path);

if (map == NULL) {
mapscript_throw_mapserver_exception("Failed to open map file \"%s\", or map file error." TSRMLS_CC, string);
mapscript_throw_mapserver_exception("Error while loading map file from string." TSRMLS_CC);
return;
}

Expand Down
1 change: 1 addition & 0 deletions mapserver.h
Expand Up @@ -2052,6 +2052,7 @@ extern "C" {
MS_DLL_EXPORT int msLoadSymbolSet(symbolSetObj *symbolset, mapObj *map);
MS_DLL_EXPORT int msCopySymbol(symbolObj *dst, symbolObj *src, mapObj *map);
MS_DLL_EXPORT int msCopySymbolSet(symbolSetObj *dst, symbolSetObj *src, mapObj *map);
MS_DLL_EXPORT int msCopyHashTable(hashTableObj *dst, hashTableObj *src);
MS_DLL_EXPORT void msInitSymbolSet(symbolSetObj *symbolset);
MS_DLL_EXPORT symbolObj *msGrowSymbolSet( symbolSetObj *symbolset );
MS_DLL_EXPORT int msAddImageSymbol(symbolSetObj *symbolset, char *filename);
Expand Down
17 changes: 15 additions & 2 deletions mapshape.c
Expand Up @@ -249,6 +249,10 @@ SHPHandle msSHPOpen( const char * pszLayer, const char * pszAccess )
pszFullname = (char *) msSmallMalloc(strlen(pszBasename) + 5);
sprintf( pszFullname, "%s.shp", pszBasename );
psSHP->fpSHP = fopen(pszFullname, pszAccess );
if( psSHP->fpSHP == NULL ) {
sprintf( pszFullname, "%s.SHP", pszBasename );
psSHP->fpSHP = fopen(pszFullname, pszAccess );
}
if( psSHP->fpSHP == NULL ) {
msFree(pszBasename);
msFree(pszFullname);
Expand All @@ -258,6 +262,10 @@ SHPHandle msSHPOpen( const char * pszLayer, const char * pszAccess )

sprintf( pszFullname, "%s.shx", pszBasename );
psSHP->fpSHX = fopen(pszFullname, pszAccess );
if( psSHP->fpSHX == NULL ) {
sprintf( pszFullname, "%s.SHX", pszBasename );
psSHP->fpSHX = fopen(pszFullname, pszAccess );
}
if( psSHP->fpSHX == NULL ) {
msFree(pszBasename);
msFree(pszFullname);
Expand Down Expand Up @@ -1753,9 +1761,14 @@ int msShapefileWhichShapes(shapefileObj *shpfile, rectObj rect, int debug)

/* deal with case where sourcename is of the form 'file.shp' */
sourcename = msStrdup(shpfile->source);
/* TODO: need to add case-insensitive handling! */
s = strstr(sourcename, ".shp");
if( s ) *s = '\0';
if( s )
*s = '\0';
else {
s = strstr(sourcename, ".SHP");
if( s )
*s = '\0';
}

filename = (char *)malloc(strlen(sourcename)+strlen(MS_INDEX_EXTENSION)+1);
MS_CHECK_ALLOC(filename, strlen(sourcename)+strlen(MS_INDEX_EXTENSION)+1, MS_FAILURE);
Expand Down
2 changes: 1 addition & 1 deletion maptemplate.c
Expand Up @@ -2058,7 +2058,7 @@ static int processShpxyTag(layerObj *layer, char **line, shapeObj *shape)
}

/* build the per point format strings (version 1 contains the coordinate seperator, version 2 doesn't) */
pointFormatLength = strlen("xh") + strlen("xf") + strlen("yh") + strlen("yf") + strlen("cs") + 10 + 1;
pointFormatLength = strlen(xh) + strlen(xf) + strlen(yh) + strlen(yf) + strlen(cs) + 12 + 1;
pointFormat1 = (char *) msSmallMalloc(pointFormatLength);
snprintf(pointFormat1, pointFormatLength, "%s%%.%dlf%s%s%%.%dlf%s%s", xh, precision, xf, yh, precision, yf, cs);
pointFormat2 = (char *) msSmallMalloc(pointFormatLength);
Expand Down
4 changes: 4 additions & 0 deletions maptree.c
Expand Up @@ -126,6 +126,10 @@ SHPTreeHandle msSHPDiskTreeOpen(const char * pszTree, int debug)
pszFullname = (char *) msSmallMalloc(strlen(pszBasename) + 5);
sprintf( pszFullname, "%s%s", pszBasename, MS_INDEX_EXTENSION);
psTree->fp = fopen(pszFullname, "rb" );
if( psTree->fp == NULL ) {
sprintf( pszFullname, "%s.QIX", pszBasename);
psTree->fp = fopen(pszFullname, "rb" );
}

msFree(pszBasename); /* don't need these any more */
msFree(pszFullname);
Expand Down
97 changes: 56 additions & 41 deletions mapuvraster.c
Expand Up @@ -333,13 +333,23 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
{
uvRasterLayerInfo *uvlinfo = (uvRasterLayerInfo *) layer->layerinfo;
imageObj *image_tmp;
mapObj map_tmp;
outputFormatObj *outputformat = NULL;
mapObj *map_tmp;
double map_cellsize;
unsigned int spacing;
int width, height, u_src_off, v_src_off, i, x, y;
char **alteredProcessing = NULL;
char **savedProcessing = NULL;

/*
** Allocate mapObj structure
*/
map_tmp = (mapObj *)msSmallCalloc(sizeof(mapObj),1);
if(initMap(map_tmp) == -1) { /* initialize this map */
msFree(map_tmp);
return(MS_FAILURE);
}

if (layer->debug)
msDebug("Entering msUVRASTERLayerWhichShapes().\n");

Expand All @@ -358,6 +368,7 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
"msUVRASTERLayerWhichShapes()" );
return MS_FAILURE;
}

/* -------------------------------------------------------------------- */
/* Determine desired spacing. Default to 32 if not otherwise set */
/* -------------------------------------------------------------------- */
Expand All @@ -371,58 +382,59 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
height = (int)ceil(layer->map->height/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;
map_tmp->cellsize = map_cellsize*spacing;

if (layer->debug)
msDebug("msUVRASTERLayerWhichShapes(): width: %d, height: %d, cellsize: %g\n",
width, height, map_tmp.cellsize);
width, height, map_tmp->cellsize);

/* Initialize our dummy map */
MS_INIT_COLOR(map_tmp.imagecolor, 255,255,255,255);
map_tmp.resolution = layer->map->resolution;
map_tmp.defresolution = layer->map->defresolution;
map_tmp.outputformat = (outputFormatObj *) msSmallCalloc(1,sizeof(outputFormatObj));
uvlinfo->band_count = map_tmp.outputformat->bands = 2;
map_tmp.outputformat->name = NULL;
map_tmp.outputformat->driver = NULL;
map_tmp.outputformat->refcount = 0;
map_tmp.outputformat->vtable = NULL;
map_tmp.outputformat->device = NULL;
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 = 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->projection);
MS_INIT_COLOR(map_tmp->imagecolor, 255,255,255,255);
map_tmp->resolution = layer->map->resolution;
map_tmp->defresolution = layer->map->defresolution;

outputformat = (outputFormatObj *) msSmallCalloc(1,sizeof(outputFormatObj));
outputformat->bands = uvlinfo->band_count = 2;
outputformat->name = NULL;
outputformat->driver = NULL;
outputformat->refcount = 0;
outputformat->vtable = NULL;
outputformat->device = NULL;
outputformat->renderer = MS_RENDER_WITH_RAWDATA;
outputformat->imagemode = MS_IMAGEMODE_FLOAT32;
msAppendOutputFormat(map_tmp, outputformat);

msCopyHashTable(&map_tmp->configoptions, &layer->map->configoptions);
map_tmp->mappath = msStrdup(layer->map->mappath);
map_tmp->shapepath = msStrdup(layer->map->shapepath);
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;

msCopyProjection(&map_tmp->projection, &layer->projection);

if (layer->debug == 5)
msDebug("msUVRASTERLayerWhichShapes(): extent: %g %d %g %g\n",
map_tmp.extent.minx, map_tmp.extent.miny,
map_tmp.extent.maxx, map_tmp.extent.maxy);
msDebug("msUVRASTERLayerWhichShapes(): extent: %g %g %g %g\n",
map_tmp->extent.minx, map_tmp->extent.miny,
map_tmp->extent.maxx, map_tmp->extent.maxy);

/* important to use that function, to compute map
geotransform, used by the resampling*/
msMapSetSize(&map_tmp, width, height);
msMapSetSize(map_tmp, width, height);

if (layer->debug == 5)
msDebug("msUVRASTERLayerWhichShapes(): geotransform: %g %g %g %g %g %g\n",
map_tmp.gt.geotransform[0], map_tmp.gt.geotransform[1],
map_tmp.gt.geotransform[2], map_tmp.gt.geotransform[3],
map_tmp.gt.geotransform[4], map_tmp.gt.geotransform[5]);
map_tmp->gt.geotransform[0], map_tmp->gt.geotransform[1],
map_tmp->gt.geotransform[2], map_tmp->gt.geotransform[3],
map_tmp->gt.geotransform[4], map_tmp->gt.geotransform[5]);

uvlinfo->extent = map_tmp.extent;
uvlinfo->extent = map_tmp->extent;

image_tmp = msImageCreate(width, height, map_tmp.outputformat,
NULL, NULL, map_tmp.resolution, map_tmp.defresolution,
&(map_tmp.imagecolor));
image_tmp = msImageCreate(width, height, map_tmp->outputformatlist[0],
NULL, NULL, map_tmp->resolution, map_tmp->defresolution,
&(map_tmp->imagecolor));

/* Default set to AVERAGE resampling */
if( CSLFetchNameValue( layer->processing, "RESAMPLE" ) == NULL ) {
Expand All @@ -434,14 +446,16 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
layer->processing = alteredProcessing;
}

if (msDrawRasterLayerLow(&map_tmp, layer, image_tmp, NULL ) == MS_FAILURE) {
msSetError(MS_MISCERR, "Unable to draw raster data.", NULL, "msUVRASTERLayerWhichShapes()" );
if (msDrawRasterLayerLow(map_tmp, layer, image_tmp, NULL ) == MS_FAILURE) {
msSetError(MS_MISCERR, "Unable to draw raster data.", "msUVRASTERLayerWhichShapes()");
return MS_FAILURE;
}

/* restore the saved processing */
if (alteredProcessing != NULL)
if (alteredProcessing != NULL) {
layer->processing = savedProcessing;
CSLDestroy(alteredProcessing);
}

/* free old query arrays */
if (uvlinfo->u) {
Expand Down Expand Up @@ -484,6 +498,7 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
}

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

uvlinfo->next_shape = 0;

Expand Down
12 changes: 10 additions & 2 deletions mapwcs.c
Expand Up @@ -139,17 +139,18 @@ int msWCSException(mapObj *map, const char *code, const char *locator,
{
char *pszEncodedVal = NULL;
const char *encoding;
char version_string[OWS_VERSION_MAXLEN];

if( version == NULL )
version = "1.0.0";

#if defined(USE_LIBXML2)
if( msOWSParseVersionString(version) >= OWS_2_0_0 )
return msWCSException20( map, code, locator, version );
return msWCSException20( map, code, locator, msOWSGetVersionString(msOWSParseVersionString(version), version_string) );
#endif

if( msOWSParseVersionString(version) >= OWS_1_1_0 )
return msWCSException11( map, code, locator, version );
return msWCSException11( map, code, locator, msOWSGetVersionString(msOWSParseVersionString(version), version_string) );

encoding = msOWSLookupMetadata(&(map->web.metadata), "CO", "encoding");
if (encoding)
Expand Down Expand Up @@ -2162,6 +2163,13 @@ int msWCSDispatch(mapObj *map, cgiRequestObj *request, owsRequestObj *ows_reques
return msWCSException(map, "InvalidParameterValue",
"request", "2.0.1");
}
else if (status == MS_DONE) {
/* MS_DONE means, that the exception has already been written to the IO
buffer.
*/
msWCSFreeParamsObj20(params);
return MS_FAILURE;
}
}

/* check if all layer names are valid NCNames */
Expand Down

0 comments on commit 6199608

Please sign in to comment.