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

Function msTiledSHPOpenFile

mapshape.c:1867–1962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1865}
1866
1867int msTiledSHPOpenFile(layerObj *layer)
1868{
1869 int i;
1870 char *filename, tilename[MS_MAXPATHLEN], szPath[MS_MAXPATHLEN];
1871 char tiFileAbsDir[MS_MAXPATHLEN];
1872
1873 msTiledSHPLayerInfo *tSHP=NULL;
1874
1875 if ( msCheckParentPointer(layer->map,"map")==MS_FAILURE )
1876 return MS_FAILURE;
1877
1878 /* allocate space for a shapefileObj using layer->layerinfo */
1879 tSHP = (msTiledSHPLayerInfo *) malloc(sizeof(msTiledSHPLayerInfo));
1880 MS_CHECK_ALLOC(tSHP, sizeof(msTiledSHPLayerInfo), MS_FAILURE);
1881
1882 tSHP->shpfile = (shapefileObj *) malloc(sizeof(shapefileObj));
1883 if (tSHP->shpfile == NULL)
1884 {
1885 msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msTiledSHPOpenFile()",
1886 __FILE__, __LINE__, sizeof(shapefileObj));
1887 free(tSHP);
1888 return MS_FAILURE;
1889 }
1890
1891 tSHP->tileshpfile = NULL; /* may need this if not using a tile layer, look for malloc later */
1892 layer->layerinfo = tSHP;
1893
1894 tSHP->tilelayerindex = msGetLayerIndex(layer->map, layer->tileindex);
1895 if(tSHP->tilelayerindex != -1) { /* does the tileindex reference another layer */
1896 int status;
1897 layerObj *tlp;
1898
1899 tlp = (GET_LAYER(layer->map, tSHP->tilelayerindex));
1900
1901 if(tlp->connectiontype != MS_SHAPEFILE) {
1902 msSetError(MS_SDEERR, "Tileindex layer must be a shapefile.", "msTiledSHPOpenFile()");
1903 return(MS_FAILURE);
1904 }
1905
1906 status = msLayerOpen(tlp);
1907 if(status != MS_SUCCESS) return(MS_FAILURE);
1908
1909 /* build item list */
1910 status = msLayerWhichItems(tlp, MS_FALSE, NULL);
1911 if(status != MS_SUCCESS) return(MS_FAILURE);
1912
1913 tSHP->tileshpfile = (shapefileObj *) tlp->layerinfo; /* shapefiles use layerinfo to point to a shapefileObj */
1914
1915 } else { /* or reference a shapefile directly */
1916
1917 /* we need tSHP->tileshpfile if we're not working with a layer */
1918 tSHP->tileshpfile = (shapefileObj *) malloc(sizeof(shapefileObj));
1919 if (tSHP->tileshpfile == NULL)
1920 {
1921 msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msTiledSHPOpenFile()",
1922 __FILE__, __LINE__, sizeof(shapefileObj));
1923 free(tSHP->shpfile);
1924 free(tSHP);

Callers

nothing calls this directly

Calls 12

msCheckParentPointerFunction · 0.85
msSetErrorFunction · 0.85
msGetLayerIndexFunction · 0.85
msLayerOpenFunction · 0.85
msLayerWhichItemsFunction · 0.85
msShapefileOpenFunction · 0.85
msBuildPath3Function · 0.85
msBuildPathFunction · 0.85
msDBFGetItemIndexFunction · 0.85
msTileIndexAbsoluteDirFunction · 0.85
msDBFReadStringAttributeFunction · 0.85
msTiledSHPTryOpenFunction · 0.85

Tested by

no test coverage detected