int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image) { int i, status; char annotate=MS_TRUE, cache=MS_FALSE; shapeObj shape; int maxnumstyles=1; featureListNodeObjPtr shpcache=NULL, current=NULL; colorObj colorbuffer[MS_MAXCLASSES]; if(!layer->resultcache || map->querymap.style == MS_NORMAL) return(msDrawLayer(map, layer, image)); if(!layer->data && !layer->tileindex && !layer->connection && !layer->features) return(MS_SUCCESS); // no data associated with this layer, not an error since layer may be used as a template from MapScript if(layer->type == MS_LAYER_QUERY) return(MS_SUCCESS); // query only layers simply can't be drawn, not an error if(map->querymap.style == MS_HILITE) { // first, draw normally, but don't return status = msDrawLayer(map, layer, image); if(status != MS_SUCCESS) return(MS_FAILURE); // oops } if((layer->status != MS_ON) && (layer->status != MS_DEFAULT)) return(MS_SUCCESS); if(msEvalContext(map, layer->requires) == MS_FALSE) return(MS_SUCCESS); annotate = msEvalContext(map, layer->labelrequires); if(map->scale > 0) { if((layer->maxscale > 0) && (map->scale > layer->maxscale)) return(MS_SUCCESS); if((layer->minscale > 0) && (map->scale <= layer->minscale)) return(MS_SUCCESS); if((layer->labelmaxscale != -1) && (map->scale >= layer->labelmaxscale)) annotate = MS_FALSE; if((layer->labelminscale != -1) && (map->scale < layer->labelminscale)) annotate = MS_FALSE; } // reset layer pen values just in case the map has been previously processed msClearLayerPenValues(layer); // if MS_HILITE, alter the first class (always at least 1 class) - kafka - zmenit logiku highlight if(map->querymap.style == MS_HILITE) { for(i=0; inumclasses; i++) { if(layer->type == MS_LAYER_POLYGON){ //for polygon layers the first style is highlighted colorbuffer[i] = layer->class[i].styles[0].color; layer->class[i].styles[0].color = map->querymap.color; } else { if(MS_VALID_COLOR(layer->class[i].styles[layer->class[i].numstyles-1].color)) { colorbuffer[i] = layer->class[i].styles[layer->class[i].numstyles-1].color; // save the color from the TOP style layer->class[i].styles[layer->class[i].numstyles-1].color = map->querymap.color; } else if(MS_VALID_COLOR(layer->class[i].styles[layer->class[i].numstyles-1].outlinecolor)) { colorbuffer[i] = layer->class[i].styles[layer->class[i].numstyles-1].outlinecolor; // if no color, save the outlinecolor from the TOP style layer->class[i].styles[layer->class[i].numstyles-1].outlinecolor = map->querymap.color; } } } } // open this layer status = msLayerOpen(layer); if(status != MS_SUCCESS) return(MS_FAILURE); // build item list status = msLayerWhichItems(layer, MS_FALSE, annotate, NULL); // FIX: results have already been classified (this may change) if(status != MS_SUCCESS) return(MS_FAILURE); msInitShape(&shape); for(i=0; iresultcache->numresults; i++) { status = msLayerGetShape(layer, &shape, layer->resultcache->results[i].tileindex, layer->resultcache->results[i].shapeindex); if(status != MS_SUCCESS) return(MS_FAILURE); shape.classindex = layer->resultcache->results[i].classindex; if(layer->class[shape.classindex].status == MS_OFF) { msFreeShape(&shape); continue; } cache = MS_FALSE; if(layer->type == MS_LAYER_LINE && layer->class[shape.classindex].numstyles > 1) cache = MS_TRUE; // only line layers with multiple styles need be cached (I don't think POLYLINE layers need caching - SDL) if(annotate && (layer->class[shape.classindex].text.string || layer->labelitem) && layer->class[shape.classindex].label.size != -1) shape.text = msShapeGetAnnotation(layer, &shape); if(cache) status = msDrawShape(map, layer, &shape, image, 0); // draw only the first style else status = msDrawShape(map, layer, &shape, image, -1); // all styles if(status != MS_SUCCESS) { msLayerClose(layer); return MS_FAILURE; } if(shape.numlines == 0) { // once clipped the shape didn't need to be drawn msFreeShape(&shape); continue; } if(cache) { if(insertFeatureList(&shpcache, &shape) == NULL) return(MS_FAILURE); // problem adding to the cache } maxnumstyles = MS_MAX(maxnumstyles, layer->class[shape.classindex].numstyles); msFreeShape(&shape); } if(shpcache) { int s; for(s=1; snext) { if(layer->class[current->shape.classindex].numstyles > s) msDrawLineSymbol(&map->symbolset, image, ¤t->shape, &(layer->class[current->shape.classindex].styles[s]), layer->scalefactor); } } freeFeatureList(shpcache); shpcache = NULL; } // if MS_HILITE, restore values if(map->querymap.style == MS_HILITE) { for(i=0; inumclasses; i++) { if(layer->type == MS_LAYER_POLYGON) layer->class[i].styles[0].color = colorbuffer[i]; else { if(MS_VALID_COLOR(layer->class[i].styles[layer->class[i].numstyles-1].color)) layer->class[i].styles[layer->class[i].numstyles-1].color = colorbuffer[i]; else if(MS_VALID_COLOR(layer->class[i].styles[layer->class[i].numstyles-1].outlinecolor)) layer->class[i].styles[layer->class[i].numstyles-1].outlinecolor = colorbuffer[i]; // if no color, restore outlinecolor for the TOP style } } } msLayerClose(layer); return(MS_SUCCESS); }