@@ -2887,6 +2887,17 @@ static int msOGRGetSymbolId(symbolSetObj *symbolset, const char *pszSymbolId,
2887
2887
}
2888
2888
#endif
2889
2889
2890
+ #ifdef USE_OGR
2891
+
2892
+ static int msOGRUpdateStyleParseLabel (mapObj *map, layerObj *layer, classObj *c,
2893
+ OGRStyleToolH hLabelStyle);
2894
+ static int msOGRUpdateStyleParsePen (mapObj *map, layerObj *layer, classObj *c,
2895
+ OGRStyleToolH hPenStyle, int bIsBrush);
2896
+ static int msOGRUpdateStyleParseBrush (mapObj *map, layerObj *layer, classObj *c,
2897
+ OGRStyleToolH hBrushStyle, int * pbIsBrush);
2898
+ static int msOGRUpdateStyleParseSymbol (mapObj *map, layerObj *layer, classObj *c,
2899
+ OGRStyleToolH hSymbolStyle);
2900
+
2890
2901
/* *********************************************************************
2891
2902
* msOGRUpdateStyle()
2892
2903
*
@@ -2895,13 +2906,9 @@ static int msOGRGetSymbolId(symbolSetObj *symbolset, const char *pszSymbolId,
2895
2906
* msOGRUpdateStyleFromString
2896
2907
**********************************************************************/
2897
2908
2898
- #ifdef USE_OGR
2899
2909
static int msOGRUpdateStyle (OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer, classObj *c)
2900
2910
{
2901
- GBool bIsNull, bIsBrush=MS_FALSE;
2902
- int r=0 ,g=0 ,b=0 ,t=0 ;
2903
- double dfTmp;
2904
- int try_addimage_if_notfound = MS_FALSE;
2911
+ GBool bIsBrush=MS_FALSE;
2905
2912
int numParts = OGR_SM_GetPartCount (hStyleMgr, NULL );
2906
2913
2907
2914
/* ------------------------------------------------------------------
@@ -2928,7 +2935,34 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
2928
2935
OGR_ST_SetUnit (hStylePart, OGRSTUPixel, map->cellsize *72.0 *39.37 );
2929
2936
2930
2937
if (eStylePartType == OGRSTCLabel) {
2931
- OGRStyleToolH hLabelStyle = hStylePart;
2938
+ int ret = msOGRUpdateStyleParseLabel (map, layer, c, hStylePart);
2939
+ if ( ret != MS_SUCCESS )
2940
+ return ret;
2941
+ } else if (eStylePartType == OGRSTCPen) {
2942
+ int ret = msOGRUpdateStyleParsePen (map, layer, c, hStylePart, bIsBrush);
2943
+ if ( ret != MS_SUCCESS )
2944
+ return ret;
2945
+ } else if (eStylePartType == OGRSTCBrush) {
2946
+ int ret = msOGRUpdateStyleParseBrush (map, layer, c, hStylePart, &bIsBrush);
2947
+ if ( ret != MS_SUCCESS )
2948
+ return ret;
2949
+ } else if (eStylePartType == OGRSTCSymbol) {
2950
+ int ret = msOGRUpdateStyleParseSymbol (map, layer, c, hStylePart);
2951
+ if ( ret != MS_SUCCESS )
2952
+ return ret;
2953
+ }
2954
+
2955
+ OGR_ST_Destroy (hStylePart);
2956
+
2957
+ }
2958
+ return MS_SUCCESS;
2959
+ }
2960
+
2961
+ static int msOGRUpdateStyleParseLabel (mapObj *map, layerObj *layer, classObj *c,
2962
+ OGRStyleToolH hLabelStyle)
2963
+ {
2964
+ GBool bIsNull;
2965
+ int r=0 ,g=0 ,b=0 ,t=0 ;
2932
2966
2933
2967
// Enclose the text string inside quotes to make sure it is seen
2934
2968
// as a string by the parser inside loadExpression(). (bug185)
@@ -3073,8 +3107,15 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3073
3107
if (!bFont) {
3074
3108
c->labels [0 ]->size = MS_MEDIUM;
3075
3109
}
3076
- } else if (eStylePartType == OGRSTCPen) {
3077
- OGRStyleToolH hPenStyle = hStylePart;
3110
+
3111
+ return MS_SUCCESS;
3112
+ }
3113
+
3114
+ static int msOGRUpdateStyleParsePen (mapObj *map, layerObj *layer, classObj *c,
3115
+ OGRStyleToolH hPenStyle, int bIsBrush)
3116
+ {
3117
+ GBool bIsNull;
3118
+ int r=0 ,g=0 ,b=0 ,t=0 ;
3078
3119
3079
3120
const char *pszPenName, *pszPattern, *pszCap, *pszJoin;
3080
3121
colorObj oPenColor;
@@ -3201,7 +3242,7 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3201
3242
// This is a multipart symbology, so pen defn goes in the
3202
3243
// overlaysymbol params
3203
3244
if (msMaybeAllocateClassStyle (c, 1 )) {
3204
- OGR_ST_Destroy (hStylePart );
3245
+ OGR_ST_Destroy (hPenStyle );
3205
3246
return (MS_FAILURE);
3206
3247
}
3207
3248
@@ -3219,7 +3260,7 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3219
3260
} else {
3220
3261
// Single part symbology
3221
3262
if (msMaybeAllocateClassStyle (c, 0 )) {
3222
- OGR_ST_Destroy (hStylePart );
3263
+ OGR_ST_Destroy (hPenStyle );
3223
3264
return (MS_FAILURE);
3224
3265
}
3225
3266
@@ -3240,8 +3281,14 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3240
3281
memcpy (c->styles [0 ]->pattern , pattern, sizeof (double ) * patternlength);
3241
3282
}
3242
3283
3243
- } else if (eStylePartType == OGRSTCBrush) {
3244
- OGRStyleToolH hBrushStyle = hStylePart;
3284
+ return MS_SUCCESS;
3285
+ }
3286
+
3287
+ static int msOGRUpdateStyleParseBrush (mapObj *map, layerObj *layer, classObj *c,
3288
+ OGRStyleToolH hBrushStyle, int * pbIsBrush)
3289
+ {
3290
+ GBool bIsNull;
3291
+ int r=0 ,g=0 ,b=0 ,t=0 ;
3245
3292
3246
3293
const char *pszBrushName = OGR_ST_GetParamStr (hBrushStyle,
3247
3294
OGRSTBrushId,
@@ -3250,7 +3297,7 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3250
3297
3251
3298
/* We need 1 style */
3252
3299
if (msMaybeAllocateClassStyle (c, 0 )) {
3253
- OGR_ST_Destroy (hStylePart );
3300
+ OGR_ST_Destroy (hBrushStyle );
3254
3301
return (MS_FAILURE);
3255
3302
}
3256
3303
@@ -3259,7 +3306,7 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3259
3306
if (pszBrushName && strstr (pszBrushName, " ogr-brush-1" ) != NULL ) {
3260
3307
MS_INIT_COLOR (c->styles [0 ]->color , -1 , -1 , -1 , 255 );
3261
3308
} else {
3262
- bIsBrush = TRUE ;
3309
+ *pbIsBrush = TRUE ;
3263
3310
const char *pszColor = OGR_ST_GetParamStr (hBrushStyle,
3264
3311
OGRSTBrushFColor,
3265
3312
&bIsNull);
@@ -3312,12 +3359,19 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3312
3359
}
3313
3360
}
3314
3361
}
3315
- } else if (eStylePartType == OGRSTCSymbol) {
3316
- OGRStyleToolH hSymbolStyle = hStylePart;
3362
+
3363
+ return MS_SUCCESS;
3364
+ }
3365
+
3366
+ static int msOGRUpdateStyleParseSymbol (mapObj *map, layerObj *layer, classObj *c,
3367
+ OGRStyleToolH hSymbolStyle)
3368
+ {
3369
+ GBool bIsNull;
3370
+ int r=0 ,g=0 ,b=0 ,t=0 ;
3317
3371
3318
3372
/* We need 1 style */
3319
3373
if (msMaybeAllocateClassStyle (c, 0 )) {
3320
- OGR_ST_Destroy (hStylePart );
3374
+ OGR_ST_Destroy (hSymbolStyle );
3321
3375
return (MS_FAILURE);
3322
3376
}
3323
3377
@@ -3343,7 +3397,7 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3343
3397
c->styles [0 ]->angle = OGR_ST_GetParamNum (hSymbolStyle,
3344
3398
OGRSTSymbolAngle,
3345
3399
&bIsNull);
3346
- dfTmp = OGR_ST_GetParamNum (hSymbolStyle, OGRSTSymbolSize, &bIsNull);
3400
+ double dfTmp = OGR_ST_GetParamNum (hSymbolStyle, OGRSTSymbolSize, &bIsNull);
3347
3401
if (!bIsNull)
3348
3402
c->styles [0 ]->size = dfTmp;
3349
3403
@@ -3357,7 +3411,7 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3357
3411
if (bIsNull)
3358
3412
pszName = NULL ;
3359
3413
3360
- try_addimage_if_notfound = MS_FALSE;
3414
+ int try_addimage_if_notfound = MS_FALSE;
3361
3415
#ifdef USE_CURL
3362
3416
if (pszName && strncasecmp (pszName, " http" , 4 ) == 0 )
3363
3417
try_addimage_if_notfound =MS_TRUE;
@@ -3366,13 +3420,10 @@ static int msOGRUpdateStyle(OGRStyleMgrH hStyleMgr, mapObj *map, layerObj *layer
3366
3420
c->styles [0 ]->symbol = msOGRGetSymbolId (&(map->symbolset ),
3367
3421
pszName,
3368
3422
" default-marker" , try_addimage_if_notfound);
3369
- }
3370
3423
3371
- OGR_ST_Destroy (hStylePart);
3372
-
3373
- }
3374
- return MS_SUCCESS;
3424
+ return MS_SUCCESS;
3375
3425
}
3426
+
3376
3427
#endif /* USE_OGR */
3377
3428
3378
3429
0 commit comments