Skip to content

Commit

Permalink
Preserve style strings in class objects to boost OGR autostyle perfor…
Browse files Browse the repository at this point in the history
…mance
  • Loading branch information
szekerest committed Oct 2, 2012
1 parent b8f75e5 commit 6ebf39e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mapfile.c
Expand Up @@ -3073,6 +3073,8 @@ int initClass(classObj *class)

initLeader(&(class->leader));

class->stylestring = NULL;

return(0);
}

Expand Down Expand Up @@ -3114,6 +3116,7 @@ int freeClass(classObj *class)

msFree(class->keyimage);
freeLabelLeader(&(class->leader));
msFree(class->stylestring);

return MS_SUCCESS;
}
Expand Down
26 changes: 26 additions & 0 deletions mapogr.cpp
Expand Up @@ -2814,6 +2814,14 @@ static int msOGRLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c,
return(MS_FAILURE);
}

const char* stylestring = NULL;
if (psInfo->hLastFeature) {
stylestring = OGR_F_GetStyleString(psInfo->hLastFeature);
if (stylestring && c->stylestring && EQUAL(c->stylestring, stylestring)) {
return (MS_SUCCESS); /* already configured */
}
}

/* ------------------------------------------------------------------
* Reset style info in the class to defaults
* the only members we don't touch are name, expression, and join/query stuff
Expand All @@ -2836,6 +2844,13 @@ static int msOGRLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c,
}

RELEASE_OGR_LOCK;

msFree(c->stylestring);
if (stylestring)
c->stylestring = msStrdup(stylestring);
else
c->stylestring = NULL;

return nRetVal;
#else
/* ------------------------------------------------------------------
Expand Down Expand Up @@ -2865,6 +2880,8 @@ int msOGRUpdateStyleFromString(mapObj *map, layerObj *layer, classObj *c,
const char *stylestring)
{
#ifdef USE_OGR
if (stylestring && c->stylestring && EQUAL(c->stylestring, stylestring))
return (MS_SUCCESS); /* already configured */
/* ------------------------------------------------------------------
* Reset style info in the class to defaults
* the only members we don't touch are name, expression, and join/query stuff
Expand All @@ -2887,6 +2904,15 @@ int msOGRUpdateStyleFromString(mapObj *map, layerObj *layer, classObj *c,
OGR_SM_Destroy(hStyleMgr);

RELEASE_OGR_LOCK;

if (nRetVal == MS_SUCCESS) {
/* save style string */
msFree(c->stylestring);
if (stylestring)
c->stylestring = msStrdup(stylestring);
else
c->stylestring = NULL;
}
return nRetVal;
#else
/* ------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions mapserver.h
Expand Up @@ -1124,6 +1124,7 @@ extern "C" {

char *group;
labelLeaderObj leader;
char *stylestring;
} classObj;

/************************************************************************/
Expand Down

0 comments on commit 6ebf39e

Please sign in to comment.