TopographyFile::TopographyFile(struct zzip_dir *_dir, const char *filename, fixed _threshold, fixed _label_threshold, fixed _important_label_threshold, const Color _color, int _label_field, ResourceId _icon, ResourceId _big_icon, unsigned _pen_width) :dir(_dir), first(NULL), label_field(_label_field), icon(_icon), big_icon(_big_icon), pen_width(_pen_width), color(_color), scale_threshold(_threshold), label_threshold(_label_threshold), important_label_threshold(_important_label_threshold), cache_bounds(GeoBounds::Invalid()) { if (msShapefileOpen(&file, "rb", dir, filename, 0) == -1) return; if (file.numshapes == 0) { msShapefileClose(&file); return; } shapes.ResizeDiscard(file.numshapes); std::fill(shapes.begin(), shapes.end(), ShapeList(NULL)); if (dir != NULL) ++dir->refcount; ++serial; }
TopographyFile::TopographyFile(struct zzip_dir *_dir, const char *filename, fixed _threshold, fixed _label_threshold, fixed _important_label_threshold, const Color thecolor, int _label_field, int _icon, int _pen_width) :dir(_dir), first(NULL), label_field(_label_field), icon(_icon), pen_width(_pen_width), color(thecolor), scale_threshold(_threshold), label_threshold(_label_threshold), important_label_threshold(_important_label_threshold) { if (msShapefileOpen(&file, "rb", dir, filename, 0) == -1) return; if (file.numshapes == 0) { msShapefileClose(&file); return; } shapes.resize_discard(file.numshapes); std::fill(shapes.begin(), shapes.end(), ShapeList(NULL)); if (dir != NULL) ++dir->refcount; cache_bounds.west = cache_bounds.east = cache_bounds.south = cache_bounds.north = Angle::zero(); }
TopographyFile::TopographyFile(zzip_dir *_dir, const char *filename, double _threshold, double _label_threshold, double _important_label_threshold, const Color _color, int _label_field, ResourceId _icon, ResourceId _big_icon, unsigned _pen_width) :dir(_dir), first(nullptr), label_field(_label_field), icon(_icon), big_icon(_big_icon), pen_width(_pen_width), color(_color), scale_threshold(_threshold), label_threshold(_label_threshold), important_label_threshold(_important_label_threshold), cache_bounds(GeoBounds::Invalid()) { if (msShapefileOpen(&file, "rb", dir, filename, 0) == -1) return; if (file.numshapes == 0) { msShapefileClose(&file); return; } const auto file_bounds = ImportRect(file.bounds); if (!file_bounds.Check()) { /* malformed bounds */ msShapefileClose(&file); return; } center = file_bounds.GetCenter(); shapes.ResizeDiscard(file.numshapes); std::fill(shapes.begin(), shapes.end(), ShapeList(nullptr)); if (dir != nullptr) ++dir->refcount; ++serial; }
int msUVRASTERLayerGetExtent(layerObj *layer, rectObj *extent) { char szPath[MS_MAXPATHLEN]; mapObj *map = layer->map; double adfGeoTransform[6]; int nXSize, nYSize; GDALDatasetH hDS; shapefileObj *tileshpfile; int tilelayerindex = -1; CPLErr eErr = CE_Failure; char *decrypted_path; if( (!layer->data || strlen(layer->data) == 0) && layer->tileindex == NULL) { /* should we be issuing a specific error about not supporting extents for tileindexed raster layers? */ return MS_FAILURE; } if( map == NULL ) return MS_FAILURE; /* If the layer use a tileindex, return the extent of the tileindex shapefile/referenced layer */ if (layer->tileindex) { tilelayerindex = msGetLayerIndex(map, layer->tileindex); if(tilelayerindex != -1) /* does the tileindex reference another layer */ return msLayerGetExtent(GET_LAYER(map, tilelayerindex), extent); else { tileshpfile = (shapefileObj *) malloc(sizeof(shapefileObj)); MS_CHECK_ALLOC(tileshpfile, sizeof(shapefileObj), MS_FAILURE); if(msShapefileOpen(tileshpfile, "rb", msBuildPath3(szPath, map->mappath, map->shapepath, layer->tileindex), MS_TRUE) == -1) if(msShapefileOpen(tileshpfile, "rb", msBuildPath(szPath, map->mappath, layer->tileindex), MS_TRUE) == -1) return MS_FAILURE; *extent = tileshpfile->bounds; msShapefileClose(tileshpfile); free(tileshpfile); return MS_SUCCESS; } } msTryBuildPath3(szPath, map->mappath, map->shapepath, layer->data); decrypted_path = msDecryptStringTokens( map, szPath ); msAcquireLock( TLOCK_GDAL ); if( decrypted_path ) { hDS = GDALOpen(decrypted_path, GA_ReadOnly ); msFree( decrypted_path ); } else hDS = NULL; if( hDS != NULL ) { nXSize = GDALGetRasterXSize( hDS ); nYSize = GDALGetRasterYSize( hDS ); eErr = GDALGetGeoTransform( hDS, adfGeoTransform ); GDALClose( hDS ); } msReleaseLock( TLOCK_GDAL ); if( hDS == NULL || eErr != CE_None ) { return MS_FAILURE; } /* If this appears to be an ungeoreferenced raster than flip it for mapservers purposes. */ if( adfGeoTransform[5] == 1.0 && adfGeoTransform[3] == 0.0 ) { adfGeoTransform[5] = -1.0; adfGeoTransform[3] = nYSize; } extent->minx = adfGeoTransform[0]; extent->maxy = adfGeoTransform[3]; extent->maxx = adfGeoTransform[0] + nXSize * adfGeoTransform[1]; extent->miny = adfGeoTransform[3] + nYSize * adfGeoTransform[5]; return MS_SUCCESS; }