| 5239 | |
| 5240 | |
| 5241 | int msSaveMap(mapObj *map, char *filename) |
| 5242 | { |
| 5243 | int i, indent=0; |
| 5244 | FILE *stream; |
| 5245 | char szPath[MS_MAXPATHLEN]; |
| 5246 | colorObj c; |
| 5247 | |
| 5248 | if(!map) { |
| 5249 | msSetError(MS_MISCERR, "Map is undefined.", "msSaveMap()"); |
| 5250 | return(-1); |
| 5251 | } |
| 5252 | |
| 5253 | if(!filename) { |
| 5254 | msSetError(MS_MISCERR, "Filename is undefined.", "msSaveMap()"); |
| 5255 | return(-1); |
| 5256 | } |
| 5257 | |
| 5258 | stream = fopen(msBuildPath(szPath, map->mappath, filename), "w"); |
| 5259 | if(!stream) { |
| 5260 | msSetError(MS_IOERR, "(%s)", "msSaveMap()", filename); |
| 5261 | return(-1); |
| 5262 | } |
| 5263 | |
| 5264 | writeBlockBegin(stream, indent, "MAP"); |
| 5265 | writeHashTableInline(stream, indent, "CONFIG", &(map->configoptions)); |
| 5266 | writeString(stream, indent, "DATAPATTERN", NULL, map->datapattern); /* depricated */ |
| 5267 | writeNumber(stream, indent, "DEBUG", 0, map->debug); |
| 5268 | writeNumber(stream, indent, "DEFRESOLUTION", 72.0, map->defresolution); |
| 5269 | writeExtent(stream, indent, "EXTENT", map->extent); |
| 5270 | writeString(stream, indent, "FONTSET", NULL, map->fontset.filename); |
| 5271 | MS_INIT_COLOR(c,255,255,255,255); |
| 5272 | writeColor(stream, indent, "IMAGECOLOR", &c, &(map->imagecolor)); |
| 5273 | writeString(stream, indent, "IMAGETYPE", NULL, map->imagetype); |
| 5274 | writeKeyword(stream, indent, "INTERLACE", map->interlace, 2, MS_TRUE, "TRUE", MS_FALSE, "FALSE"); |
| 5275 | writeNumber(stream, indent, "MAXSIZE", MS_MAXIMAGESIZE_DEFAULT, map->maxsize); |
| 5276 | writeString(stream, indent, "NAME", NULL, map->name); |
| 5277 | writeNumber(stream, indent, "RESOLUTION", 72.0, map->resolution); |
| 5278 | writeString(stream, indent, "SHAPEPATH", NULL, map->shapepath); |
| 5279 | writeDimension(stream, indent, "SIZE", map->width, map->height, NULL, NULL); |
| 5280 | writeKeyword(stream, indent, "STATUS", map->status, 2, MS_ON, "ON", MS_OFF, "OFF"); |
| 5281 | writeString(stream, indent, "SYMBOLSET", NULL, map->symbolset.filename); |
| 5282 | writeString(stream, indent, "TEMPLATEPATTERN", NULL, map->templatepattern); /* depricated */ |
| 5283 | writeKeyword(stream, indent, "TRANSPARENT", map->transparent, 2, MS_TRUE, "TRUE", MS_FALSE, "FALSE"); |
| 5284 | writeKeyword(stream, indent, "UNITS", map->units, 7, MS_INCHES, "INCHES", MS_FEET ,"FEET", MS_MILES, "MILES", MS_METERS, "METERS", MS_KILOMETERS, "KILOMETERS", MS_NAUTICALMILES, "NAUTICALMILES", MS_DD, "DD"); |
| 5285 | writeLineFeed(stream); |
| 5286 | |
| 5287 | writeOutputformat(stream, indent, map); |
| 5288 | |
| 5289 | /* write symbol with INLINE tag in mapfile */ |
| 5290 | for(i=0; i<map->symbolset.numsymbols; i++) { |
| 5291 | if(map->symbolset.symbol[i]->inmapfile) writeSymbol(map->symbolset.symbol[i], stream); |
| 5292 | } |
| 5293 | |
| 5294 | writeProjection(stream, indent, &(map->projection)); |
| 5295 | |
| 5296 | writeLegend(stream, indent, &(map->legend)); |
| 5297 | writeQueryMap(stream, indent, &(map->querymap)); |
| 5298 | writeReferenceMap(stream, indent, &(map->reference)); |
no test coverage detected