| 463 | |
| 464 | |
| 465 | int msDrawBarChartLayer(mapObj *map, layerObj *layer, imageObj *image) |
| 466 | { |
| 467 | shapeObj shape; |
| 468 | int status=MS_SUCCESS; |
| 469 | const char *chartSizeProcessingKey=msLayerGetProcessingKey( layer,"CHART_SIZE" ); |
| 470 | const char *barMax=msLayerGetProcessingKey( layer,"CHART_BAR_MAXVAL" ); |
| 471 | const char *barMin=msLayerGetProcessingKey( layer,"CHART_BAR_MINVAL" ); |
| 472 | float width,height; |
| 473 | float barWidth; |
| 474 | float *values; |
| 475 | styleObj **styles; |
| 476 | pointObj center; |
| 477 | float barMaxVal,barMinVal; |
| 478 | int numvalues = layer->numclasses; |
| 479 | if(chartSizeProcessingKey==NULL) |
| 480 | { |
| 481 | width=height=20; |
| 482 | } |
| 483 | else |
| 484 | { |
| 485 | switch(sscanf(chartSizeProcessingKey ,"%f %f",&width,&height)) { |
| 486 | case 2: |
| 487 | break; |
| 488 | case 1: |
| 489 | height = width; |
| 490 | break; |
| 491 | default: |
| 492 | msSetError(MS_MISCERR, "msDrawChart format error for processing key \"CHART_SIZE\"", "msDrawBarChartLayer()"); |
| 493 | return MS_FAILURE; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | if(barMax){ |
| 498 | if(sscanf(barMax,"%f",&barMaxVal)!=1) { |
| 499 | msSetError(MS_MISCERR, "Error reading value for processing key \"CHART_BAR_MAXVAL\"", "msDrawBarChartLayer()"); |
| 500 | return MS_FAILURE; |
| 501 | } |
| 502 | } |
| 503 | if(barMin) { |
| 504 | if(sscanf(barMin,"%f",&barMinVal)!=1) { |
| 505 | msSetError(MS_MISCERR, "Error reading value for processing key \"CHART_BAR_MINVAL\"", "msDrawBarChartLayer()"); |
| 506 | return MS_FAILURE; |
| 507 | } |
| 508 | } |
| 509 | if(barMin && barMax && barMinVal>=barMaxVal) { |
| 510 | msSetError(MS_MISCERR, "\"CHART_BAR_MINVAL\" must be less than \"CHART_BAR_MAXVAL\"", "msDrawBarChartLayer()"); |
| 511 | return MS_FAILURE; |
| 512 | } |
| 513 | barWidth=(float)width/(float)layer->numclasses; |
| 514 | if(!barWidth) |
| 515 | { |
| 516 | msSetError(MS_MISCERR, "Specified width of chart too small to fit given number of classes", "msDrawBarChartLayer()"); |
| 517 | return MS_FAILURE; |
| 518 | } |
| 519 | |
| 520 | msInitShape(&shape); |
| 521 | |
| 522 | values=(float*)calloc(numvalues,sizeof(float)); |
no test coverage detected