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

Function msQueryByShape

mapquery.c:1644–1897  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1642}
1643
1644int msQueryByShape(mapObj *map)
1645{
1646 int start, stop=0, l;
1647 shapeObj shape, *qshape=NULL;
1648 layerObj *lp;
1649 char status;
1650 double distance, tolerance, layer_tolerance;
1651 rectObj searchrect;
1652
1653 int nclasses = 0;
1654 int *classgroup = NULL;
1655 double minfeaturesize = -1;
1656
1657 if(map->query.type != MS_QUERY_BY_SHAPE) {
1658 msSetError(MS_QUERYERR, "The query is not properly defined.", "msQueryByShape()");
1659 return(MS_FAILURE);
1660 }
1661
1662 if(!(map->query.shape)) {
1663 msSetError(MS_QUERYERR, "Query shape is not defined.", "msQueryByShape()");
1664 return(MS_FAILURE);
1665 }
1666 if(map->query.shape->type != MS_SHAPE_POLYGON && map->query.shape->type != MS_SHAPE_LINE && map->query.shape->type != MS_SHAPE_POINT) {
1667 msSetError(MS_QUERYERR, "Query shape MUST be a polygon, line or point.", "msQueryByShape()");
1668 return(MS_FAILURE);
1669 }
1670
1671 msInitShape(&shape);
1672 qshape = map->query.shape; /* for brevity */
1673
1674 if(map->query.layer < 0 || map->query.layer >= map->numlayers)
1675 start = map->numlayers-1;
1676 else
1677 start = stop = map->query.layer;
1678
1679 msComputeBounds(qshape); /* make sure an accurate extent exists */
1680
1681 for(l=start; l>=stop; l--) { /* each layer */
1682 lp = (GET_LAYER(map, l));
1683
1684 /* conditions may have changed since this layer last drawn, so set
1685 layer->project true to recheck projection needs (Bug #673) */
1686 lp->project = MS_TRUE;
1687
1688 /* free any previous search results, do it now in case one of the next few tests fail */
1689 if(lp->resultcache) {
1690 if(lp->resultcache->results) free(lp->resultcache->results);
1691 free(lp->resultcache);
1692 lp->resultcache = NULL;
1693 }
1694
1695 if(!msIsLayerQueryable(lp)) continue;
1696 if(lp->status == MS_OFF) continue;
1697
1698 if(map->scaledenom > 0) {
1699 if((lp->maxscaledenom > 0) && (map->scaledenom > lp->maxscaledenom)) continue;
1700 if((lp->minscaledenom > 0) && (map->scaledenom <= lp->minscaledenom)) continue;
1701 }

Callers 3

msExecuteQueryFunction · 0.85
mapObj_queryByShapeFunction · 0.85
layerObj_queryByShapeFunction · 0.85

Calls 15

msSetErrorFunction · 0.85
msInitShapeFunction · 0.85
msComputeBoundsFunction · 0.85
msIsLayerQueryableFunction · 0.85
msRasterQueryByShapeFunction · 0.85
msAdjustExtentFunction · 0.85
msInchesPerUnitFunction · 0.85
msLayerCloseFunction · 0.85
msLayerOpenFunction · 0.85
msLayerWhichItemsFunction · 0.85
msProjectionsDifferFunction · 0.85
msProjectRectFunction · 0.85

Tested by

no test coverage detected