MCPcopy Index your code
hub / github.com/MapServer/MapServer / msQueryByIndex

Function msQueryByIndex

mapquery.c:470–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470int msQueryByIndex(mapObj *map)
471{
472 layerObj *lp;
473 int status;
474
475 resultObj record;
476
477 shapeObj shape;
478 double minfeaturesize = -1;
479
480 if(map->query.type != MS_QUERY_BY_INDEX) {
481 msSetError(MS_QUERYERR, "The query is not properly defined.", "msQueryByIndex()");
482 return(MS_FAILURE);
483 }
484
485 if(map->query.layer < 0 || map->query.layer >= map->numlayers) {
486 msSetError(MS_QUERYERR, "No query layer defined.", "msQueryByIndex()");
487 return(MS_FAILURE);
488 }
489
490 lp = (GET_LAYER(map, map->query.layer));
491
492 if(!msIsLayerQueryable(lp)) {
493 msSetError(MS_QUERYERR, "Requested layer has no templates defined.", "msQueryByIndex()");
494 return(MS_FAILURE);
495 }
496
497 if(map->query.clear_resultcache) {
498 if(lp->resultcache) {
499 if(lp->resultcache->results) free(lp->resultcache->results);
500 free(lp->resultcache);
501 lp->resultcache = NULL;
502 }
503 }
504
505 msLayerClose(lp); /* reset */
506 status = msLayerOpen(lp);
507 if(status != MS_SUCCESS) return(MS_FAILURE);
508
509 /* build item list, we want *all* items */
510 status = msLayerWhichItems(lp, MS_TRUE, NULL);
511 if(status != MS_SUCCESS) return(MS_FAILURE);
512
513 if(map->query.clear_resultcache || lp->resultcache == NULL) {
514 lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
515 MS_CHECK_ALLOC(lp->resultcache, sizeof(resultCacheObj), MS_FAILURE);
516 initResultCache( lp->resultcache);
517 }
518
519 msInitShape(&shape);
520
521 record.shapeindex = map->query.shapeindex;
522 record.tileindex = map->query.tileindex;
523
524 status = msLayerGetShape(lp, &shape, &record);
525 if(status != MS_SUCCESS) {
526 msSetError(MS_NOTFOUND, "Not valid record request.", "msQueryByIndex()");
527 return(MS_FAILURE);

Callers 2

msExecuteQueryFunction · 0.85
mapObj_queryByIndexFunction · 0.85

Calls 13

msSetErrorFunction · 0.85
msIsLayerQueryableFunction · 0.85
msLayerCloseFunction · 0.85
msLayerOpenFunction · 0.85
msLayerWhichItemsFunction · 0.85
initResultCacheFunction · 0.85
msInitShapeFunction · 0.85
msLayerGetShapeFunction · 0.85
Pix2LayerGeorefFunction · 0.85
msShapeCheckSizeFunction · 0.85
msFreeShapeFunction · 0.85
msShapeGetClassFunction · 0.85

Tested by

no test coverage detected