#272 closed defect (fixed)
New msMapCopy function
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | high | Milestone: | |
Component: | MapServer C Library | Version: | 4.0 |
Severity: | normal | Keywords: | |
Cc: |
Description
I noticed that the map object is always created by loading mapfile in msLoadMap() function. I wonder in the new version of MapServer if you can add something like msMapCopy() function. I feel if we can do this mapObj *srcmap = NULL; mapObj *newmap = NULL; srcmap = msLoadMap("C:\\test.map", NULL); while ( maprequest == TRUE) { newmap = msMapCopy(srcmap); /* *********************************** use newmap object to generate map image ************************************/ msFreeMap(newmap); } It will be much more efficient than loading mapfile every time.
Attachments (1)
Change History (9)
comment:2 by , 21 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
Oh, forgot to reassign to myself. -- Sean sgillies@frii.com
comment:3 by , 21 years ago
Status: | new → assigned |
---|
Have spent some days writing functions to copy mapping objects. There's enough code (~ 700 lines) that I'm reluctant to add it to mapfile.c, so I've created a mapcopy.c file. I started by cutting all the structure declarations from map.h, plus some from maptemplate.h, mapoutput.h and using these as skeletons for functions. For example, starting with the structure {...} classObj, I create an msCopyClass() function that strdups all char * attributes, memcpys all the other simple types, and calls msCopy*() functions for class attributes (style, color, etc.). Tedious! Status: msCopyMap() will make a valid map copy. All layers, classes are present. We are not copying any caches or items. Copy of hash tables is not yet implemented, so metadata is not ready yet. I am attaching the Python test script which enumerates the unit tests I've done. Even for someone new to Python, should be clear what I've tested.
comment:4 by , 21 years ago
Cc: | added |
---|
comment:5 by , 21 years ago
I started using the mapcopy code yesterday to do layer copying. I am running into problems related to the metadata copy. I know it is not yet implemented. If you do not see any inconvinience or are not working on it, I would like to implement the code in msCopyHashTable. The code would be : int msCopyHashTable(hashTableObj dst, hashTableObj src) { for (i=0;i<MS_HASHSIZE; i++) { if (src[i] != NULL) { for (tp=src[i]; tp!=NULL; tp=tp->next) msInsertHashTable(dst, tp->key, tp->data); } }
comment:7 by , 21 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Looks like assefa is using msCopyLayer in php_mapscript.c, and I've committed to mapscript.i a tested clone() method using msCopyMap() that extends mapObj and is used like this Python example: map1 = mapObj(mapfile) map2 = map1.clone() I think the conotation of 'clone' is better than 'copy'. Our new map is not an _exact_ copy because msCopyMap() only copies the properties that would be defined in a mapfile, the genes if you will. Caches are not (currently) copied. As the clone() method is working well for me, and I haven't heard otherwise from assefa about msCopyLayer in php, I'm going to call this feature request resolved as fixed. If/when bugs are found, we'll create a new issue.
comment:8 by , 21 years ago
For the record, I added the map->clone() method to PHP MapScript as well. I also fixed a few build problems and added error checking in the clone() method in mapscript.i so that it returns NULL if msCopyMap() doesn't return MS_SUCCESS.
Note:
See TracTickets
for help on using tickets.