/* setting the aggregated attributes */ static void InitShapeAttributes(layerObj* layer, clusterInfo* base) { int i; int* itemindexes = layer->iteminfo; for (i = 0; i < layer->numitems; i++) { if (base->shape.numvalues <= i) break; if (itemindexes[i] == MSCLUSTER_FEATURECOUNTINDEX) { if (base->shape.values[i]) msFree(base->shape.values[i]); base->shape.values[i] = msIntToString(base->numsiblings + 1); } else if (itemindexes[i] == MSCLUSTER_GROUPINDEX) { if (base->shape.values[i]) msFree(base->shape.values[i]); if (base->group) base->shape.values[i] = msStrdup(base->group); else base->shape.values[i] = msStrdup(""); } else if (EQUALN(layer->items[i], "Count:", 6)) { if (base->shape.values[i]) msFree(base->shape.values[i]); base->shape.values[i] = msStrdup("1"); /* initial count */ } } }
int msCopyProjectionExtended(projectionObj *dst, projectionObj *src, char ** args, int num_args) { #ifdef USE_PROJ int i; MS_COPYSTELEM(numargs); MS_COPYSTELEM(gt); MS_COPYSTELEM(automatic); for (i = 0; i < dst->numargs; i++) { /* Our destination consists of unallocated pointers */ dst->args[i] = msStrdup(src->args[i]); } for(i=0 ; i< num_args; i++) { dst->args[dst->numargs++] = msStrdup(args[i]); } if (dst->numargs != 0) { if (msProcessProjection(dst) != MS_SUCCESS) return MS_FAILURE; } #endif MS_COPYSTELEM(wellknownprojection); return MS_SUCCESS; }
static int BuildFeatureAttributes(layerObj* layer, msClusterLayerInfo* layerinfo, shapeObj* shape) { char** values; int i; int* itemindexes = layer->iteminfo; if (layer->numitems == layerinfo->srcLayer.numitems) return MS_SUCCESS; /* we don't have custom attributes, no need to reconstruct the array */ values = msSmallMalloc(sizeof(char*) * (layer->numitems)); for (i = 0; i < layer->numitems; i++) { if (itemindexes[i] == MSCLUSTER_FEATURECOUNTINDEX) { values[i] = NULL; /* not yet assigned */ } else if (itemindexes[i] == MSCLUSTER_GROUPINDEX) { values[i] = NULL; /* not yet assigned */ } else if (shape->values[itemindexes[i]]) values[i] = msStrdup(shape->values[itemindexes[i]]); else values[i] = msStrdup(""); } if (shape->values) msFreeCharArray(shape->values, shape->numvalues); shape->values = values; shape->numvalues = layer->numitems; return MS_SUCCESS; }
int msPostMapParseOutputFormatSetup( mapObj *map ) { outputFormatObj *format; /* If IMAGETYPE not set use the first user defined OUTPUTFORMAT. If none, use the first default format. */ if( map->imagetype == NULL && map->numoutputformats > 0 ) map->imagetype = msStrdup(map->outputformatlist[0]->name); if( map->imagetype == NULL) map->imagetype = msStrdup(defaultoutputformats[0].name); /* select the current outputformat into map->outputformat */ format = msSelectOutputFormat( map, map->imagetype ); if( format == NULL ) { msSetError(MS_MISCERR, "Unable to select IMAGETYPE `%s'.", "msPostMapParseOutputFormatSetup()", map->imagetype ? map->imagetype : "(null)" ); return MS_FAILURE; } msApplyOutputFormat( &(map->outputformat), format, map->transparent, map->interlace, map->imagequality ); return MS_SUCCESS; }
struct hashObj *msInsertHashTable(hashTableObj *table, const char *key, const char *value) { struct hashObj *tp; unsigned hashval; if (!table || !key || !value) { msSetError(MS_HASHERR, "Invalid hash table or key", "msInsertHashTable"); return NULL; } for (tp=table->items[hash(key)]; tp!=NULL; tp=tp->next) if(strcasecmp(key, tp->key) == 0) break; if (tp == NULL) { /* not found */ tp = (struct hashObj *) malloc(sizeof(*tp)); MS_CHECK_ALLOC(tp, sizeof(*tp), NULL); tp->key = msStrdup(key); hashval = hash(key); tp->next = table->items[hashval]; table->items[hashval] = tp; table->numitems++; } else { free(tp->data); } if ((tp->data = msStrdup(value)) == NULL) return NULL; return tp; }
/* msSetErrorFile() ** ** Set output target, ready to write to it, open file if necessary ** ** If pszRelToPath != NULL then we will try to make the value relative to ** this path if it is not absolute already and it's not one of the special ** values (stderr, stdout, windowsdebug) ** ** Returns MS_SUCCESS/MS_FAILURE */ int msSetErrorFile(const char *pszErrorFile, const char *pszRelToPath) { char extended_path[MS_MAXPATHLEN]; debugInfoObj *debuginfo = msGetDebugInfoObj(); if (strcmp(pszErrorFile, "stderr") != 0 && strcmp(pszErrorFile, "stdout") != 0 && strcmp(pszErrorFile, "windowsdebug") != 0) { /* Try to make the path relative */ if(msBuildPath(extended_path, pszRelToPath, pszErrorFile) == NULL) return MS_FAILURE; pszErrorFile = extended_path; } if (debuginfo && debuginfo->errorfile && pszErrorFile && strcmp(debuginfo->errorfile, pszErrorFile) == 0) { /* Nothing to do, already writing to the right place */ return MS_SUCCESS; } /* Close current output file if any */ msCloseErrorFile(); /* NULL or empty target will just close current output and return */ if (pszErrorFile == NULL || *pszErrorFile == '\0') return MS_SUCCESS; if (strcmp(pszErrorFile, "stderr") == 0) { debuginfo->fp = stderr; debuginfo->errorfile = msStrdup(pszErrorFile); debuginfo->debug_mode = MS_DEBUGMODE_STDERR; } else if (strcmp(pszErrorFile, "stdout") == 0) { debuginfo->fp = stdout; debuginfo->errorfile = msStrdup(pszErrorFile); debuginfo->debug_mode = MS_DEBUGMODE_STDOUT; } else if (strcmp(pszErrorFile, "windowsdebug") == 0) { #ifdef _WIN32 debuginfo->errorfile = msStrdup(pszErrorFile); debuginfo->fp = NULL; debuginfo->debug_mode = MS_DEBUGMODE_WINDOWSDEBUG; #else msSetError(MS_MISCERR, "'MS_ERRORFILE windowsdebug' is available only on Windows platforms.", "msSetErrorFile()"); return MS_FAILURE; #endif } else { debuginfo->fp = fopen(pszErrorFile, "a"); if (debuginfo->fp == NULL) { msSetError(MS_MISCERR, "Failed to open MS_ERRORFILE %s", "msSetErrorFile()", pszErrorFile); return MS_FAILURE; } debuginfo->errorfile = msStrdup(pszErrorFile); debuginfo->debug_mode = MS_DEBUGMODE_FILE; } return MS_SUCCESS; }
/* eventually add a class to the layer to get the diameter from an attribute */ int pieLayerProcessDynamicDiameter(layerObj *layer) { const char *chartRangeProcessingKey=NULL; char *attrib; float mindiameter=-1, maxdiameter, minvalue, maxvalue; classObj *newclass; styleObj *newstyle; const char *chartSizeProcessingKey=msLayerGetProcessingKey( layer,"CHART_SIZE" ); if(chartSizeProcessingKey != NULL) return MS_FALSE; chartRangeProcessingKey=msLayerGetProcessingKey( layer,"CHART_SIZE_RANGE" ); if(chartRangeProcessingKey==NULL) return MS_FALSE; attrib = msSmallMalloc(strlen(chartRangeProcessingKey)+1); switch(sscanf(chartRangeProcessingKey,"%s %f %f %f %f",attrib, &mindiameter,&maxdiameter,&minvalue,&maxvalue)) { case 1: /*we only have the attribute*/ case 5: /*we have the attribute and the four range values*/ break; default: free(attrib); msSetError(MS_MISCERR, "Chart Layer format error for processing key \"CHART_RANGE\"", "msDrawChartLayer()"); return MS_FAILURE; } /*create a new class in the layer containing the wanted attribute * as the SIZE of its first STYLE*/ newclass=msGrowLayerClasses(layer); if(newclass==NULL) { free(attrib); return MS_FAILURE; } initClass(newclass); layer->numclasses++; /*create and attach a new styleObj to our temp class * and bind the wanted attribute to its SIZE */ newstyle=msGrowClassStyles(newclass); if(newstyle==NULL) { free(attrib); return MS_FAILURE; } initStyle(newstyle); newclass->numstyles++; newclass->name=(char*)msStrdup("__MS_SIZE_ATTRIBUTE_"); newstyle->bindings[MS_STYLE_BINDING_SIZE].item=msStrdup(attrib); newstyle->numbindings++; free(attrib); return MS_TRUE; }
int KmlRenderer::mergeRasterBuffer(imageObj *image, rasterBufferObj *rb) { assert(rb && rb->type == MS_BUFFER_BYTE_RGBA); char *tmpFileName = NULL; char *tmpUrl = NULL; FILE *tmpFile = NULL; tmpFileName = msTmpFile(NULL, MapPath, image->imagepath, "png"); tmpFile = fopen(tmpFileName,"wb"); if (tmpFile) { if (!aggFormat->vtable) msInitializeRendererVTable(aggFormat); msSaveRasterBuffer(map,rb,tmpFile,aggFormat); tmpUrl = msStrdup( image->imageurl); tmpUrl = msStringConcatenate(tmpUrl, (char *)(msGetBasename(tmpFileName))); tmpUrl = msStringConcatenate(tmpUrl, ".png"); createGroundOverlayNode(LayerNode, tmpUrl, currentLayer); msFree(tmpFileName); msFree(tmpUrl); fclose(tmpFile); return MS_SUCCESS; } else { msSetError(MS_IOERR,"Failed to create file for kml overlay","KmlRenderer::mergeRasterBuffer()"); return MS_FAILURE; } }
int msMySQLJoinPrepare(joinObj *join, shapeObj *shape) { #ifndef USE_MYSQL msSetError(MS_QUERYERR, "MySQL support not available (compile with --with-mysql)", "msMySQLJoinPrepare()"); return(MS_FAILURE); #else msMySQLJoinInfo *joininfo = join->joininfo; if(!joininfo) { msSetError(MS_JOINERR, "Join connection has not be created.", "msMySQLJoinPrepare()"); return(MS_FAILURE); } if(!shape) { msSetError(MS_JOINERR, "Shape to be joined is empty.", "msMySQLJoinPrepare()"); return(MS_FAILURE); } if(!shape->values) { msSetError(MS_JOINERR, "Shape to be joined has no attributes.", "msMySQLJoinPrepare()"); return(MS_FAILURE); } joininfo->nextrecord = 0; /* starting with the first record */ if(joininfo->target) free(joininfo->target); /* clear last target */ joininfo->target = msStrdup(shape->values[joininfo->fromindex]); return(MS_SUCCESS); #endif }
int msCSVJoinPrepare(joinObj *join, shapeObj *shape) { msCSVJoinInfo *joininfo = join->joininfo; if(!joininfo) { msSetError(MS_JOINERR, "Join connection has not be created.", "msCSVJoinPrepare()"); return(MS_FAILURE); } if(!shape) { msSetError(MS_JOINERR, "Shape to be joined is empty.", "msCSVJoinPrepare()"); return(MS_FAILURE); } if(!shape->values) { msSetError(MS_JOINERR, "Shape to be joined has no attributes.", "msCSVJoinPrepare()"); return(MS_FAILURE); } joininfo->nextrow = 0; /* starting with the first record */ if(joininfo->target) free(joininfo->target); /* clear last target */ joininfo->target = msStrdup(shape->values[joininfo->fromindex]); return(MS_SUCCESS); }
faceCacheObj *getFontFace(cairoCacheData *cache, const char *font) { faceCacheObj *newface = NULL; faceCacheObj *cur=cache->facecache; while(cur) { if(!strcmp(cur->path,font)) return cur; cur = cur->next; } newface = malloc(sizeof(faceCacheObj)); if(FT_New_Face(cache->library, font, 0, &(newface->ftface))) { msSetError(MS_RENDERERERR,"Freetype failed to open font %s","getFontFace()",font); free(newface); return NULL; } /* Try to select charmap */ if (!newface->ftface->charmap) { if( FT_Select_Charmap(newface->ftface, FT_ENCODING_MS_SYMBOL) ) FT_Select_Charmap(newface->ftface, FT_ENCODING_APPLE_ROMAN ); } newface->next = cache->facecache; cache->facecache = newface; newface->face = cairo_ft_font_face_create_for_ft_face(newface->ftface, 0); cairo_font_face_set_user_data (newface->face, &newface->facekey, &(newface->ftface), (cairo_destroy_func_t) NULL); // we call FT_Done_Face ourselves in freeFaceCache newface->path = msStrdup(font); return newface; }
/********************************************************************** * msWFSExecuteGetFeature() * Returns the temporary gml file name. User shpuld free the return string. **********************************************************************/ char *msWFSExecuteGetFeature(layerObj *lp) { #ifdef USE_WFS_LYR char *gmltmpfile = NULL; msWFSLayerInfo *psInfo = NULL; if (lp == NULL || lp->connectiontype != MS_WFS) return NULL; msWFSLayerOpen(lp, NULL, NULL); psInfo =(msWFSLayerInfo*)lp->wfslayerinfo; if (psInfo && psInfo->pszGMLFilename) gmltmpfile = msStrdup(psInfo->pszGMLFilename); msWFSLayerClose(lp); return gmltmpfile; #else /* ------------------------------------------------------------------ * WFS CONNECTION Support not included... * ------------------------------------------------------------------ */ msSetError(MS_WFSCONNERR, "WFS CLIENT CONNECTION support is not available.", "msExecuteWFSGetFeature()"); return NULL; #endif /* USE_WFS_LYR */ }
/* get the group text when creating the clusters */ char *msClusterGetGroupText(expressionObj* expression, shapeObj *shape) { char *tmpstr=NULL; if(expression->string) { switch(expression->type) { case(MS_STRING): tmpstr = msStrdup(expression->string); break; case(MS_EXPRESSION): { int status; parseObj p; p.shape = shape; p.expr = expression; p.expr->curtoken = p.expr->tokens; /* reset */ p.type = MS_PARSE_TYPE_STRING; status = yyparse(&p); if (status != 0) { msSetError(MS_PARSEERR, "Failed to process text expression: %s", "msClusterGetGroupText", expression->string); return NULL; } tmpstr = p.result.strval; break; } default: break; } } return(tmpstr); }
void msImageStartLayerIM(mapObj *map, layerObj *layer, imageObj *image){ DEBUG_IF printf("ImageStartLayerIM\n<BR>"); free(lname); if (layer->name) lname = msStrdup(layer->name); else lname = msStrdup("NONE"); if (dxf == 2){ im_iprintf(&layerStr, "LAYER\n%s\n", lname); } else if (dxf) { im_iprintf(&layerStr, " 0\nLAYER\n 2\n%s\n" " 70\n 64\n 6\nCONTINUOUS\n", lname); } lastcolor = -1; }
faceCacheObj *getFontFace(cairoCacheData *cache, char *font) { faceCacheObj *newface = NULL; faceCacheObj *cur=cache->facecache; while(cur) { if(!strcmp(cur->path,font)) return cur; cur = cur->next; } newface = malloc(sizeof(faceCacheObj)); if(FT_New_Face(cache->library, font, 0, &(newface->ftface))) { msSetError(MS_RENDERERERR,"Freetype failed to open font %s","getFontFace()",font); free(newface); return NULL; } newface->next = cache->facecache; cache->facecache = newface; newface->face = cairo_ft_font_face_create_for_ft_face(newface->ftface, 0); cairo_font_face_set_user_data (newface->face, &newface->facekey, &(newface->ftface), (cairo_destroy_func_t) FT_Done_Face); newface->path = msStrdup(font); return newface; }
void msStyleSetGeomTransform(styleObj *s, char *transform) { msFree(s->_geomtransform.string); if (!transform) { s->_geomtransform.type = MS_GEOMTRANSFORM_NONE; s->_geomtransform.string = NULL; return; } s->_geomtransform.string = msStrdup(transform); if(!strncasecmp("start",transform,5)) { s->_geomtransform.type = MS_GEOMTRANSFORM_START; } else if(!strncasecmp("end",transform,3)) { s->_geomtransform.type = MS_GEOMTRANSFORM_END; } else if(!strncasecmp("vertices",transform,8)) { s->_geomtransform.type = MS_GEOMTRANSFORM_VERTICES; } else if(!strncasecmp("bbox",transform,4)) { s->_geomtransform.type = MS_GEOMTRANSFORM_BBOX; } else if(!strncasecmp("labelpnt",transform,8)) { s->_geomtransform.type = MS_GEOMTRANSFORM_LABELPOINT; } else if(!strncasecmp("labelpoly",transform,9)) { s->_geomtransform.type = MS_GEOMTRANSFORM_LABELPOLY; } else if(!strncasecmp("centroid",transform,8)) { s->_geomtransform.type = MS_GEOMTRANSFORM_CENTROID; } else { s->_geomtransform.type = MS_GEOMTRANSFORM_NONE; msSetError(MS_MISCERR,"unknown transform expression","msStyleSetGeomTransform()"); msFree(s->_geomtransform.string); s->_geomtransform.string = NULL; } }
static void msContourLayerInfoInitialize(layerObj *layer) { contourLayerInfo *clinfo = (contourLayerInfo *) layer->layerinfo; if (clinfo != NULL) return; clinfo = (contourLayerInfo *) msSmallCalloc(1,sizeof(contourLayerInfo)); layer->layerinfo = clinfo; clinfo->hOrigDS = NULL; clinfo->hDS = NULL; clinfo->extent.minx = -1.0; clinfo->extent.miny = -1.0; clinfo->extent.maxx = -1.0; clinfo->extent.maxy = -1.0; initLayer(&clinfo->ogrLayer, layer->map); clinfo->ogrLayer.type = layer->type; clinfo->ogrLayer.debug = layer->debug; clinfo->ogrLayer.connectiontype = MS_OGR; clinfo->ogrLayer.name = msStrdup(layer->name); clinfo->ogrLayer.connection = (char*)msSmallMalloc(strlen(clinfo->ogrLayer.name)+13); sprintf(clinfo->ogrLayer.connection, "__%s_CONTOUR__", clinfo->ogrLayer.name); clinfo->ogrLayer.units = layer->units; }
char* FLTGetTimeExpression(FilterEncodingNode *psFilterNode, layerObj *lp) { char* pszExpression = NULL; const char* pszTimeField; const char* pszTimeValue; if (psFilterNode == NULL || lp == NULL) return NULL; if (psFilterNode->eType != FILTER_NODE_TYPE_TEMPORAL) return NULL; pszTimeValue = FLTGetDuring(psFilterNode, &pszTimeField); if (pszTimeField && pszTimeValue) { expressionObj old_filter; msInitExpression(&old_filter); msCopyExpression(&old_filter, &lp->filter); /* save existing filter */ msFreeExpression(&lp->filter); if (msLayerSetTimeFilter(lp, pszTimeValue, pszTimeField) == MS_TRUE) { pszExpression = msStrdup(lp->filter.string); } msCopyExpression(&lp->filter, &old_filter); /* restore old filter */ msFreeExpression(&old_filter); } return pszExpression; }
/* Function that parses multiple options in the a list. It also supports min/maxscaledenom checks. ie. "CONTOUR_INTERVAL=0,3842942:10" */ static char* msContourGetOption(layerObj *layer, const char *name) { int c, i, found = MS_FALSE; char **values, **tmp, **options; double maxscaledenom, minscaledenom; char *value = NULL; options = CSLFetchNameValueMultiple(layer->processing, name); c = CSLCount(options); for (i=0; i<c && found == MS_FALSE; ++i) { values = CSLTokenizeStringComplex(options[i], ":", FALSE, FALSE); if (CSLCount(values) == 2) { tmp = CSLTokenizeStringComplex(values[0], ",", FALSE, FALSE); if (CSLCount(tmp) == 2) { minscaledenom = atof(tmp[0]); maxscaledenom = atof(tmp[1]); if (layer->map->scaledenom <= 0 || (((maxscaledenom <= 0) || (layer->map->scaledenom <= maxscaledenom)) && ((minscaledenom <= 0) || (layer->map->scaledenom > minscaledenom)))) { value = msStrdup(values[1]); found = MS_TRUE; } } CSLDestroy(tmp); } CSLDestroy(values); } CSLDestroy(options); return value; }
char *msProjectionObj2OGCWKT( projectionObj *projection ) { #if !defined(USE_GDAL) && !defined(USE_OGR) msSetError(MS_OGRERR, "Not implemented since neither OGR nor GDAL is enabled.", "msProjectionObj2OGCWKT()"); return NULL; #else /* defined USE_GDAL or USE_OGR */ OGRSpatialReferenceH hSRS; char *pszWKT=NULL, *pszProj4; int nLength = 0, i; OGRErr eErr; if( projection->proj == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* Form arguments into a full Proj.4 definition string. */ /* -------------------------------------------------------------------- */ for( i = 0; i < projection->numargs; i++ ) nLength += strlen(projection->args[i]) + 2; pszProj4 = (char *) CPLMalloc(nLength+2); pszProj4[0] = '\0'; for( i = 0; i < projection->numargs; i++ ) { strcat( pszProj4, "+" ); strcat( pszProj4, projection->args[i] ); strcat( pszProj4, " " ); } /* -------------------------------------------------------------------- */ /* Ingest the string into OGRSpatialReference. */ /* -------------------------------------------------------------------- */ hSRS = OSRNewSpatialReference( NULL ); eErr = OSRImportFromProj4( hSRS, pszProj4 ); CPLFree( pszProj4 ); /* -------------------------------------------------------------------- */ /* Export as a WKT string. */ /* -------------------------------------------------------------------- */ if( eErr == OGRERR_NONE ) eErr = OSRExportToWkt( hSRS, &pszWKT ); OSRDestroySpatialReference( hSRS ); if( pszWKT ) { char *pszWKT2 = msStrdup(pszWKT); CPLFree( pszWKT ); return pszWKT2; } else return NULL; #endif /* defined USE_GDAL or USE_OGR */ }
void msSetPROJ_LIB( const char *proj_lib, const char *pszRelToPath ) { #ifdef USE_PROJ static int finder_installed = 0; char *extended_path = NULL; /* Handle relative path if applicable */ if( proj_lib && pszRelToPath && proj_lib[0] != '/' && proj_lib[0] != '\\' && !(proj_lib[0] != '\0' && proj_lib[1] == ':') ) { struct stat stat_buf; extended_path = (char*) msSmallMalloc(strlen(pszRelToPath) + strlen(proj_lib) + 10); sprintf( extended_path, "%s/%s", pszRelToPath, proj_lib ); #ifndef S_ISDIR # define S_ISDIR(x) ((x) & S_IFDIR) #endif if( stat( extended_path, &stat_buf ) == 0 && S_ISDIR(stat_buf.st_mode) ) proj_lib = extended_path; } msAcquireLock( TLOCK_PROJ ); if( finder_installed == 0 && proj_lib != NULL) { finder_installed = 1; pj_set_finder( msProjFinder ); } if (proj_lib == NULL) pj_set_finder(NULL); if( ms_proj_lib != NULL ) { free( ms_proj_lib ); ms_proj_lib = NULL; } if( last_filename != NULL ) { free( last_filename ); last_filename = NULL; } if( proj_lib != NULL ) ms_proj_lib = msStrdup( proj_lib ); msReleaseLock( TLOCK_PROJ ); if ( extended_path ) msFree( extended_path ); #endif }
static outputFormatObj *msAllocOutputFormat( mapObj *map, const char *name, const char *driver ) { outputFormatObj *format; /* -------------------------------------------------------------------- */ /* Allocate the format object. */ /* -------------------------------------------------------------------- */ format = (outputFormatObj *) calloc(1,sizeof(outputFormatObj)); if( format == NULL ) { msSetError( MS_MEMERR, NULL, "msAllocOutputFormat()" ); return NULL; } /* -------------------------------------------------------------------- */ /* Initialize various fields. */ /* -------------------------------------------------------------------- */ format->bands = 1; format->name = msStrdup(name); format->driver = msStrdup(driver); format->refcount = 0; format->vtable = NULL; format->device = NULL; format->imagemode = MS_IMAGEMODE_RGB; /* -------------------------------------------------------------------- */ /* Attach to map. */ /* -------------------------------------------------------------------- */ if( map != NULL ) { map->numoutputformats++; if( map->outputformatlist == NULL ) map->outputformatlist = (outputFormatObj **) malloc(sizeof(void*)); else map->outputformatlist = (outputFormatObj **) realloc(map->outputformatlist, sizeof(void*) * map->numoutputformats ); map->outputformatlist[map->numoutputformats-1] = format; format->refcount++; } return format; }
/* update the shape attributes (aggregate) */ static void UpdateShapeAttributes(layerObj* layer, clusterInfo* base, clusterInfo* current) { int i; int* itemindexes = layer->iteminfo; for (i = 0; i < layer->numitems; i++) { if (base->shape.numvalues <= i) break; if (itemindexes[i] == MSCLUSTER_FEATURECOUNTINDEX || itemindexes[i] == MSCLUSTER_GROUPINDEX) continue; if (current->shape.numvalues <= i) break; /* setting the base feature index for each cluster member */ if (itemindexes[i] == MSCLUSTER_BASEFIDINDEX) { msFree(current->shape.values[i]); current->shape.values[i] = msIntToString(base->shape.index); } if (current->shape.values[i]) { if (EQUALN(layer->items[i], "Min:", 4)) { if (strcasecmp(base->shape.values[i], current->shape.values[i]) > 0) { msFree(base->shape.values[i]); base->shape.values[i] = msStrdup(current->shape.values[i]); } } else if (EQUALN(layer->items[i], "Max:", 4)) { if (strcasecmp(base->shape.values[i], current->shape.values[i]) < 0) { msFree(base->shape.values[i]); base->shape.values[i] = msStrdup(current->shape.values[i]); } } else if (EQUALN(layer->items[i], "Sum:", 4)) { double sum = atof(base->shape.values[i]) + atof(current->shape.values[i]); msFree(base->shape.values[i]); base->shape.values[i] = msDoubleToString(sum, MS_FALSE); } else if (EQUALN(layer->items[i], "Count:", 6)) { int count = atoi(base->shape.values[i]) + 1; msFree(base->shape.values[i]); base->shape.values[i] = msIntToString(count); } } } }
/* update the shape attributes (aggregate) */ static void UpdateShapeAttributes(layerObj* layer, clusterInfo* base, clusterInfo* current) { int i; int* itemindexes = layer->iteminfo; for (i = 0; i < layer->numitems; i++) { if (base->shape.numvalues <= i) break; if (itemindexes[i] == MSCLUSTER_FEATURECOUNTINDEX || itemindexes[i] == MSCLUSTER_GROUPINDEX) continue; if (current->shape.numvalues <= i) break; if (current->shape.values[i]) { if (EQUALN(layer->items[i], "Min:", 4)) { if (strcasecmp(base->shape.values[i], current->shape.values[i]) > 0) { msFree(base->shape.values[i]); base->shape.values[i] = msStrdup(current->shape.values[i]); } } else if (EQUALN(layer->items[i], "Max:", 4)) { if (strcasecmp(base->shape.values[i], current->shape.values[i]) < 0) { msFree(base->shape.values[i]); base->shape.values[i] = msStrdup(current->shape.values[i]); } } else if (EQUALN(layer->items[i], "Sum:", 4)) { double sum = atof(base->shape.values[i]) + atof(current->shape.values[i]); msFree(base->shape.values[i]); base->shape.values[i] = msDoubleToString(sum, MS_FALSE); } else if (EQUALN(layer->items[i], "Count:", 6)) { int count = atoi(base->shape.values[i]) + 1; msFree(base->shape.values[i]); base->shape.values[i] = msIntToString(count); } else if (!EQUAL(base->shape.values[i], current->shape.values[i]) && !EQUAL(base->shape.values[i], "")) { /* clear the value if that doesn't match */ msFree(base->shape.values[i]); base->shape.values[i] = msStrdup(""); } } } }
int mapObj_setFontSet(mapObj *self, char *szFileName) { msFreeFontSet(&(self->fontset)); msInitFontSet(&(self->fontset)); // Set fontset filename self->fontset.filename = msStrdup(szFileName); return msLoadFontSet(&(self->fontset), self); }
int msInitDefaultGDALOutputFormat( outputFormatObj *format ) { GDALDriverH hDriver; msGDALInitialize(); /* -------------------------------------------------------------------- */ /* check that this driver exists. Note visiting drivers should */ /* be pretty threadsafe so don't bother acquiring the GDAL */ /* lock. */ /* -------------------------------------------------------------------- */ hDriver = GDALGetDriverByName( format->driver+5 ); if( hDriver == NULL ) { msSetError( MS_MISCERR, "No GDAL driver named `%s' available.", "msInitGDALOutputFormat()", format->driver+5 ); return MS_FAILURE; } if( GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATE, NULL ) == NULL && GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATECOPY, NULL ) == NULL ) { msSetError( MS_MISCERR, "GDAL `%s' driver does not support output.", "msInitGDALOutputFormat()", format->driver+5 ); return MS_FAILURE; } /* -------------------------------------------------------------------- */ /* Initialize the object. */ /* -------------------------------------------------------------------- */ format->imagemode = MS_IMAGEMODE_RGB; format->renderer = MS_RENDER_WITH_AGG; if( GDALGetMetadataItem( hDriver, GDAL_DMD_MIMETYPE, NULL ) != NULL ) format->mimetype = msStrdup(GDALGetMetadataItem(hDriver,GDAL_DMD_MIMETYPE,NULL)); if( GDALGetMetadataItem( hDriver, GDAL_DMD_EXTENSION, NULL ) != NULL ) format->extension = msStrdup(GDALGetMetadataItem(hDriver,GDAL_DMD_EXTENSION,NULL)); return MS_SUCCESS; }
char* KmlRenderer::getLayerName(layerObj *layer) { char stmp[20]; const char *name=NULL;; if (!layer) return NULL; name = msLookupHashTable(&layer->metadata, "ows_name"); if (name && strlen(name) > 0) return msStrdup(name); if (layer->name && strlen(layer->name) > 0) return msStrdup(layer->name); sprintf(stmp, "Layer%d",layer->index); return msStrdup(stmp); }
int msCSVJoinNext(joinObj *join) { int i,j; msCSVJoinInfo *joininfo = join->joininfo; if(!joininfo) { msSetError(MS_JOINERR, "Join connection has not be created.", "msCSVJoinNext()"); return(MS_FAILURE); } /* clear any old data */ if(join->values) { msFreeCharArray(join->values, join->numitems); join->values = NULL; } for(i=joininfo->nextrow; i<joininfo->numrows; i++) { /* find a match */ if(strcmp(joininfo->target, joininfo->rows[i][joininfo->toindex]) == 0) break; } if((join->values = (char ** )malloc(sizeof(char *)*join->numitems)) == NULL) { msSetError(MS_MEMERR, NULL, "msCSVJoinNext()"); return(MS_FAILURE); } if(i == joininfo->numrows) { /* unable to do the join */ for(j=0; j<join->numitems; j++) join->values[j] = msStrdup("\0"); /* intialize to zero length strings */ joininfo->nextrow = joininfo->numrows; return(MS_DONE); } for(j=0; j<join->numitems; j++) join->values[j] = msStrdup(joininfo->rows[i][j]); joininfo->nextrow = i+1; /* so we know where to start looking next time through */ return(MS_SUCCESS); }
static VTFactoryItemObj * createVTFItem(const char *name) { VTFactoryItemObj *pVTFI; pVTFI = (VTFactoryItemObj *)malloc(sizeof(VTFactoryItemObj)); MS_CHECK_ALLOC(pVTFI, sizeof(VTFactoryItemObj), NULL); pVTFI->name = msStrdup(name); memset(&pVTFI->vtable, 0, sizeof(layerVTableObj)); return pVTFI; }
/** * A utility function copied verbatim from `mapservutil.c` */ static void setClassGroup(layerObj *layer, char *classgroup) { int i; if(!layer || !classgroup) return; for(i=0; i<layer->numclasses; i++) { if(layer->class[i]->group && strcmp(layer->class[i]->group, classgroup) == 0) { msFree(layer->classgroup); layer->classgroup = msStrdup(classgroup); return; /* bail */ } } }