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

Function msTiledSHPGetShape

mapshape.c:2220–2277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2218}
2219
2220int msTiledSHPGetShape(layerObj *layer, shapeObj *shape, resultObj *record)
2221{
2222 char *filename, tilename[MS_MAXPATHLEN], szPath[MS_MAXPATHLEN];
2223
2224 msTiledSHPLayerInfo *tSHP=NULL;
2225 char tiFileAbsDir[MS_MAXPATHLEN];
2226
2227 long shapeindex = record->shapeindex;
2228 int tileindex = record->tileindex;
2229
2230 if ( msCheckParentPointer(layer->map,"map")==MS_FAILURE )
2231 return MS_FAILURE;
2232
2233 tSHP = layer->layerinfo;
2234 if(!tSHP) {
2235 msSetError(MS_SHPERR, "Tiled shapefile layer has not been opened.", "msTiledSHPGetShape()");
2236 return(MS_FAILURE);
2237 }
2238
2239 if((tileindex < 0) || (tileindex >= tSHP->tileshpfile->numshapes)) return(MS_FAILURE); /* invalid tile id */
2240
2241 if(tileindex != tSHP->tileshpfile->lastshape) { /* correct tile is not currenly open so open the correct tile */
2242 msShapefileClose(tSHP->shpfile); /* close current tile */
2243
2244 if(!layer->data) /* assume whole filename is in attribute field */
2245 filename = (char*) msDBFReadStringAttribute(tSHP->tileshpfile->hDBF, tileindex, layer->tileitemindex);
2246 else {
2247 snprintf(tilename, sizeof(tilename), "%s/%s", msDBFReadStringAttribute(tSHP->tileshpfile->hDBF, tileindex, layer->tileitemindex) , layer->data);
2248 filename = tilename;
2249 }
2250
2251 /* open the shapefile, since a specific tile was request an error should be generated if that tile does not exist */
2252 if(strlen(filename) == 0) return(MS_FAILURE);
2253 if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, tiFileAbsDir, layer->map->shapepath, filename), MS_TRUE) == -1) {
2254 if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename), MS_TRUE) == -1) {
2255 if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename), MS_TRUE) == -1) {
2256 return(MS_FAILURE);
2257 }
2258 }
2259 }
2260
2261 }
2262
2263 if((shapeindex < 0) || (shapeindex >= tSHP->shpfile->numshapes)) return(MS_FAILURE);
2264
2265 msSHPReadShape(tSHP->shpfile->hSHP, shapeindex, shape);
2266 tSHP->shpfile->lastshape = shapeindex;
2267
2268 if(layer->numitems > 0 && layer->iteminfo) {
2269 shape->numvalues = layer->numitems;
2270 shape->values = msDBFGetValueList(tSHP->shpfile->hDBF, shapeindex, layer->iteminfo, layer->numitems);
2271 if(!shape->values) return(MS_FAILURE);
2272 }
2273
2274 shape->tileindex = tileindex;
2275
2276 return(MS_SUCCESS);
2277}

Callers

nothing calls this directly

Calls 9

msCheckParentPointerFunction · 0.85
msSetErrorFunction · 0.85
msShapefileCloseFunction · 0.85
msDBFReadStringAttributeFunction · 0.85
msShapefileOpenFunction · 0.85
msBuildPath3Function · 0.85
msBuildPathFunction · 0.85
msSHPReadShapeFunction · 0.85
msDBFGetValueListFunction · 0.85

Tested by

no test coverage detected