diff --git a/src/rocky/AzureImageLayer.cpp b/src/rocky/AzureImageLayer.cpp index bfc55c1a..2b85f3d0 100644 --- a/src/rocky/AzureImageLayer.cpp +++ b/src/rocky/AzureImageLayer.cpp @@ -125,7 +125,7 @@ AzureImageLayer::createImageImplementation(const TileKey& key, const IOOptions& if (image_rr.status.failed()) return image_rr.status; - shared_ptr image = image_rr.value; + auto image = image_rr.value; if (image) return GeoImage(image, key.extent()); diff --git a/src/rocky/BingImageLayer.cpp b/src/rocky/BingImageLayer.cpp index 5e78c9b5..cf4698df 100644 --- a/src/rocky/BingImageLayer.cpp +++ b/src/rocky/BingImageLayer.cpp @@ -141,7 +141,7 @@ BingImageLayer::createImageImplementation(const TileKey& key, const IOOptions& i return image_rr.status; } - shared_ptr image = image_rr.value; + auto image = image_rr.value; if (image) return GeoImage(image, key.extent()); diff --git a/src/rocky/Common.h b/src/rocky/Common.h index 2598ad6f..45b99d51 100644 --- a/src/rocky/Common.h +++ b/src/rocky/Common.h @@ -37,11 +37,6 @@ namespace ROCKY_NAMESPACE { - template using shared_ptr = std::shared_ptr; - template using shared_constptr = std::shared_ptr; - template using weak_ptr = std::weak_ptr; - template using weak_constptr = std::weak_ptr; - //! application-wide unique ID. using UID = std::int32_t; @@ -81,28 +76,28 @@ namespace ROCKY_NAMESPACE Inherit(const Args&... args) : PARENT(args...) { } public: using super = Inherit; - using ptr = shared_ptr; - using constptr = shared_ptr; - using weakptr = weak_ptr; - using constweakptr = weak_ptr; + using ptr = std::shared_ptr; + using constptr = std::shared_ptr; + using weakptr = std::weak_ptr; + using constweakptr = std::weak_ptr; template - static shared_ptr create(Args&&... args) { + static std::shared_ptr create(Args&&... args) { return std::make_shared(std::forward(args)...); } template - static shared_ptr cast(shared_ptr& rhs) { + static std::shared_ptr cast(std::shared_ptr& rhs) { return std::dynamic_pointer_cast(rhs); } template - static shared_ptr cast(shared_ptr& rhs) { + static std::shared_ptr cast(std::shared_ptr& rhs) { return std::dynamic_pointer_cast(rhs); } template - static shared_ptr cast(const shared_ptr& rhs) { + static std::shared_ptr cast(const std::shared_ptr& rhs) { return std::dynamic_pointer_cast(rhs); } template - static const shared_ptr cast(const shared_ptr& rhs) { + static const std::shared_ptr cast(const std::shared_ptr& rhs) { return std::dynamic_pointer_cast(rhs); } }; diff --git a/src/rocky/ElevationLayer.cpp b/src/rocky/ElevationLayer.cpp index 888e39ba..1c8a93bf 100644 --- a/src/rocky/ElevationLayer.cpp +++ b/src/rocky/ElevationLayer.cpp @@ -192,7 +192,7 @@ ElevationLayer::normalizeNoDataValues(Heightfield* hf) const } } -shared_ptr +std::shared_ptr ElevationLayer::assembleHeightfield(const TileKey& key, const IOOptions& io) const { std::shared_ptr output; @@ -385,7 +385,7 @@ ElevationLayer::createHeightfieldInKeyProfile( const IOOptions& io) const { GeoHeightfield result; - shared_ptr hf; + std::shared_ptr hf; auto my_profile = profile(); if (!my_profile.valid() || !isOpen()) @@ -411,7 +411,7 @@ ElevationLayer::createHeightfieldInKeyProfile( else { // If the profiles are different, use a compositing method to assemble the tile. - shared_ptr hf = assembleHeightfield(key, io); + auto hf = assembleHeightfield(key, io); result = GeoHeightfield(hf, key.extent()); } @@ -452,7 +452,7 @@ namespace { struct LayerData { - shared_ptr layer; + std::shared_ptr layer; TileKey key; bool isFallback; int index; @@ -509,7 +509,7 @@ namespace bool ElevationLayerVector::populateHeightfield( - shared_ptr hf, + std::shared_ptr hf, std::vector* resolutions, const TileKey& key, const Profile& haeProfile, @@ -877,8 +877,8 @@ ElevationLayerVector::populateHeightfield( return realData; } -shared_ptr -ElevationLayer::decodeMapboxRGB(shared_ptr image) const +std::shared_ptr +ElevationLayer::decodeMapboxRGB(std::shared_ptr image) const { if (!image || !image->valid()) return nullptr; diff --git a/src/rocky/ElevationLayer.h b/src/rocky/ElevationLayer.h index fa7026ff..75361bc3 100644 --- a/src/rocky/ElevationLayer.h +++ b/src/rocky/ElevationLayer.h @@ -81,7 +81,7 @@ namespace ROCKY_NAMESPACE } //! Decodes a mapbox RGB encoded heightfield image into a heightfield. - shared_ptr decodeMapboxRGB(shared_ptr image) const; + std::shared_ptr decodeMapboxRGB(std::shared_ptr image) const; virtual ~ElevationLayer() { } @@ -94,7 +94,7 @@ namespace ROCKY_NAMESPACE private: void construct(const std::string& JSON, const IOOptions& io); - shared_ptr assembleHeightfield( + std::shared_ptr assembleHeightfield( const TileKey& key, const IOOptions& io) const; @@ -116,8 +116,7 @@ namespace ROCKY_NAMESPACE /** * Vector of elevation layers, with added methods. */ - class ROCKY_EXPORT ElevationLayerVector : - public std::vector> + class ROCKY_EXPORT ElevationLayerVector : public std::vector> { public: /** @@ -133,7 +132,7 @@ namespace ROCKY_NAMESPACE * @return True if "hf" was populated, false if no real data was available for key */ bool populateHeightfield( - shared_ptr in_out_hf, + std::shared_ptr in_out_hf, std::vector* resolutions, const TileKey& key, const Profile& hae_profile, diff --git a/src/rocky/GDAL.cpp b/src/rocky/GDAL.cpp index 337ef655..0b549115 100644 --- a/src/rocky/GDAL.cpp +++ b/src/rocky/GDAL.cpp @@ -224,9 +224,9 @@ namespace ROCKY_NAMESPACE namespace GDAL { - Result> readImage(unsigned char* data, std::size_t length, const std::string& name) + Result> readImage(unsigned char* data, std::size_t length, const std::string& name) { - shared_ptr result; + std::shared_ptr result; // generate a unique name for our temporary vsimem file: static std::atomic_int rgen(0); @@ -332,13 +332,10 @@ namespace ROCKY_NAMESPACE //................................................................... -GDAL::Driver::Driver() -{ - _threadId = std::this_thread::get_id(); -} - GDAL::Driver::~Driver() { + //Log()->info("GDAL::Driver::~Driver, _warped={}, _src={}", (std::uintptr_t)_warpedDS, (std::uintptr_t)_srcDS); + if (_warpedDS) GDALClose(_warpedDS); else if (_srcDS) @@ -572,9 +569,7 @@ GDAL::Driver::open( SRS srs(warpedSRSWKT); if (srs.valid()) { - _profile = Profile( - srs, - Box(minX, minY, maxX, maxY)); + _profile = Profile(srs, Box(minX, minY, maxX, maxY)); } if (!_profile.valid()) @@ -676,6 +671,7 @@ GDAL::Driver::open( // Get the linear units of the SRS for scaling elevation values _linearUnits = 1.0; // srs.getReportedLinearUnits(); + _open = true; return StatusOK; } @@ -864,7 +860,7 @@ GDAL::Driver::intersects(const TileKey& key) return key.extent().intersects(_extents); } -Result> +Result> GDAL::Driver::createImage(const TileKey& key, unsigned tileSize, const IOOptions& io) { if (maxDataLevel.has_value() && key.levelOfDetail() > maxDataLevel) @@ -877,7 +873,7 @@ GDAL::Driver::createImage(const TileKey& key, unsigned tileSize, const IOOptions return Status(Status::ResourceUnavailable); } - shared_ptr image; + std::shared_ptr image; const bool invert = true; diff --git a/src/rocky/GDAL.h b/src/rocky/GDAL.h index 813ef01c..48c9b8b0 100644 --- a/src/rocky/GDAL.h +++ b/src/rocky/GDAL.h @@ -73,9 +73,35 @@ namespace ROCKY_NAMESPACE optional maxDataLevel = 30; //! Constructs a new driver - Driver(); + Driver() = default; + virtual ~Driver(); + Driver(const Driver&) = delete; + + Driver(Driver&& rhs) noexcept { + _srcDS = rhs._srcDS; + _warpedDS = rhs._warpedDS; + _linearUnits = rhs._linearUnits; + _extents = rhs._extents; + _bounds = rhs._bounds; + _profile = rhs._profile; + _layer = rhs._layer; + _external = std::move(rhs._external); + _name = std::move(rhs._name); + _open = rhs._open; + rhs._srcDS = nullptr; + rhs._warpedDS = nullptr; + rhs._open = false; + rhs._profile = {}; + rhs._layer = nullptr; + rhs._external = nullptr; + } + + bool isOpen() const { + return _open; + } + //! Opens and initializes the connection to the dataset Status open( const std::string& name, @@ -85,7 +111,7 @@ namespace ROCKY_NAMESPACE const IOOptions& io); //! Creates an image if possible - Result> createImage( + Result> createImage( const TileKey& key, unsigned tileSize, const IOOptions& io); @@ -103,6 +129,7 @@ namespace ROCKY_NAMESPACE bool intersects(const TileKey&); float getInterpolatedValue(GDALRasterBand* band, double x, double y, bool applyOffset = true); + bool _open = false; GDALDataset* _srcDS = nullptr; GDALDataset* _warpedDS = nullptr; double _linearUnits = 1.0; @@ -112,7 +139,7 @@ namespace ROCKY_NAMESPACE Box _bounds; Profile _profile; const LayerBase* _layer; - shared_ptr _external; + std::shared_ptr _external; std::string _name; std::thread::id _threadId; @@ -120,7 +147,7 @@ namespace ROCKY_NAMESPACE }; //! Reads an image from raw data using the specified GDAL driver. - extern ROCKY_EXPORT Result> readImage( + extern ROCKY_EXPORT Result> readImage( unsigned char* data, std::size_t len, const std::string& gdal_driver); diff --git a/src/rocky/GDALElevationLayer.cpp b/src/rocky/GDALElevationLayer.cpp index 3ec3a7a7..82355058 100644 --- a/src/rocky/GDALElevationLayer.cpp +++ b/src/rocky/GDALElevationLayer.cpp @@ -21,7 +21,7 @@ namespace template Status openOnThisThread( const T* layer, - shared_ptr& driver, + std::shared_ptr& driver, Profile* profile, DataExtentList* out_dataExtents, const IOOptions& io) diff --git a/src/rocky/GDALElevationLayer.h b/src/rocky/GDALElevationLayer.h index 8a88211a..9dbf2fcf 100644 --- a/src/rocky/GDALElevationLayer.h +++ b/src/rocky/GDALElevationLayer.h @@ -45,7 +45,7 @@ namespace ROCKY_NAMESPACE //! Called by the constructors void construct(const std::string& JSON, const IOOptions& io); - mutable util::ThreadLocal> _drivers; + mutable util::ThreadLocal> _drivers; friend class GDAL::Driver; }; diff --git a/src/rocky/GDALImageLayer.cpp b/src/rocky/GDALImageLayer.cpp index 79955292..b81745e9 100644 --- a/src/rocky/GDALImageLayer.cpp +++ b/src/rocky/GDALImageLayer.cpp @@ -23,17 +23,22 @@ namespace template Status openOnThisThread( const T* layer, - shared_ptr& driver, + GDAL::Driver& driver, + //std::shared_ptr& driver, Profile* profile, DataExtentList* out_dataExtents, const IOOptions& io) { - driver = std::make_shared(); + Log()->info("Opening GDAL driver on thread {}", std::hash{}(std::this_thread::get_id())); + + //driver = std::make_shared(); if (layer->maxDataLevel().has_value()) - driver->maxDataLevel = layer->maxDataLevel(); + { + driver.maxDataLevel = layer->maxDataLevel(); + } - Status status = driver->open( + Status status = driver.open( layer->name(), layer, layer->tileSize(), @@ -43,9 +48,11 @@ namespace if (status.failed()) return status; - if (driver->profile().valid() && profile != nullptr) + //ROCKY_HARD_ASSERT(driver != nullptr); + + if (driver.profile().valid() && profile != nullptr) { - *profile = driver->profile(); + *profile = driver.profile(); } return StatusOK; @@ -151,16 +158,16 @@ GDALImageLayer::createImageImplementation(const TileKey& key, const IOOptions& i return status(); auto& driver = _drivers.value(); - if (driver == nullptr) + if (!driver.isOpen()) { // calling openImpl with NULL params limits the setup // since we already called this during openImplementation openOnThisThread(this, driver, nullptr, nullptr, io); } - if (driver) + if (driver.isOpen()) { - auto image = driver->createImage(key, _tileSize, io); + auto image = driver.createImage(key, _tileSize, io); if (image.value) return GeoImage(image.value, key.extent()); } diff --git a/src/rocky/GDALImageLayer.h b/src/rocky/GDALImageLayer.h index 100f5d1e..783cfacb 100644 --- a/src/rocky/GDALImageLayer.h +++ b/src/rocky/GDALImageLayer.h @@ -45,7 +45,8 @@ namespace ROCKY_NAMESPACE //! Called by the constructors void construct(const std::string& JSON, const IOOptions& io); - mutable util::ThreadLocal> _drivers; + mutable util::ThreadLocal _drivers; + //mutable util::ThreadLocal> _drivers; friend class GDAL::Driver; }; diff --git a/src/rocky/GeoHeightfield.cpp b/src/rocky/GeoHeightfield.cpp index d6887914..19953f09 100644 --- a/src/rocky/GeoHeightfield.cpp +++ b/src/rocky/GeoHeightfield.cpp @@ -32,7 +32,7 @@ GeoHeightfield::operator=(GeoHeightfield&& rhs) noexcept return *this; } -GeoHeightfield::GeoHeightfield(shared_ptr heightField, const GeoExtent& extent) : +GeoHeightfield::GeoHeightfield(std::shared_ptr heightField, const GeoExtent& extent) : _hf(heightField), _extent(extent), _minHeight(FLT_MAX), @@ -150,7 +150,7 @@ GeoHeightfield::createSubSample( double dx = destExtent.width()/(double)(width-1); double dy = destExtent.height()/(double)(height-1); - shared_ptr dest = Heightfield::create(width, height); + auto dest = Heightfield::create(width, height); double x, y; int col, row; diff --git a/src/rocky/GeoHeightfield.h b/src/rocky/GeoHeightfield.h index 66c36477..bc06f3e8 100644 --- a/src/rocky/GeoHeightfield.h +++ b/src/rocky/GeoHeightfield.h @@ -27,7 +27,7 @@ namespace ROCKY_NAMESPACE //! Constructs a new georeferenced heightfield. GeoHeightfield( - shared_ptr heightField, + std::shared_ptr heightField, const GeoExtent& extent); static GeoHeightfield INVALID; @@ -93,7 +93,7 @@ namespace ROCKY_NAMESPACE float maxHeight() const { return _maxHeight; } //! Gets a pointer to the underlying OSG heightfield. - shared_ptr heightfield() const { + std::shared_ptr heightfield() const { return _hf; } @@ -116,7 +116,7 @@ namespace ROCKY_NAMESPACE private: GeoExtent _extent; - shared_ptr _hf; + std::shared_ptr _hf; float _minHeight, _maxHeight; glm::dvec2 _resolution; diff --git a/src/rocky/GeoImage.cpp b/src/rocky/GeoImage.cpp index 2d275ab6..582d972a 100644 --- a/src/rocky/GeoImage.cpp +++ b/src/rocky/GeoImage.cpp @@ -16,7 +16,7 @@ using namespace ROCKY_NAMESPACE; namespace { #ifdef ROCKY_HAS_GDAL - shared_ptr createImageFromDataset(GDALDataset* ds) + std::shared_ptr createImageFromDataset(GDALDataset* ds) { // called internally -- GDAL lock not required @@ -140,7 +140,7 @@ namespace GDALDataset* createDataSetFromImage(const Image* image, double minX, double minY, double maxX, double maxY, const std::string &projection) { //Clone the incoming image - shared_ptr clonedImage = image->clone(); + std::shared_ptr clonedImage = image->clone(); //Flip the image clonedImage->flipVerticalInPlace(); @@ -203,7 +203,7 @@ namespace return srcDS; } - shared_ptr GDAL_reprojectImage( + std::shared_ptr GDAL_reprojectImage( const Image* srcImage, const std::string srcWKT, double srcMinX, double srcMinY, double srcMaxX, double srcMaxY, @@ -309,7 +309,7 @@ namespace return false; } - shared_ptr manualReproject( + std::shared_ptr manualReproject( const Image* image, const GeoExtent& src_extent, const GeoExtent& dest_extent, @@ -324,7 +324,7 @@ namespace height = std::min(image->width(), image->height()); } - shared_ptr result = Image::create( + std::shared_ptr result = Image::create( image->pixelFormat(), width, height, image->depth()); @@ -468,7 +468,7 @@ namespace return result; } - shared_ptr + std::shared_ptr cropImage( const Image* image, double src_minx, double src_miny, double src_maxx, double src_maxy, @@ -557,7 +557,7 @@ GeoImage::operator=(GeoImage&& rhs) noexcept return *this; } -GeoImage::GeoImage(shared_ptr image, const GeoExtent& extent) : +GeoImage::GeoImage(std::shared_ptr image, const GeoExtent& extent) : _image(image), _extent(extent) { @@ -570,7 +570,7 @@ GeoImage::valid() const return _extent.valid() && _image != nullptr; } -shared_ptr +std::shared_ptr GeoImage::image() const { return _image; @@ -669,7 +669,7 @@ GeoImage::crop( double destXMax = e.xmax(); double destYMax = e.ymax(); - shared_ptr new_image = cropImage( + auto new_image = cropImage( image().get(), _extent.xmin(), _extent.ymin(), _extent.xmax(), _extent.ymax(), destXMin, destYMin, destXMax, destYMax); diff --git a/src/rocky/GeoImage.h b/src/rocky/GeoImage.h index e5ac0963..4ec954f1 100644 --- a/src/rocky/GeoImage.h +++ b/src/rocky/GeoImage.h @@ -29,7 +29,7 @@ namespace ROCKY_NAMESPACE GeoImage& operator=(GeoImage&&) noexcept; //! Constructs a new goereferenced image. - GeoImage(shared_ptr image, const GeoExtent& extent); + GeoImage(std::shared_ptr image, const GeoExtent& extent); //! Destructor virtual ~GeoImage() { } @@ -40,7 +40,7 @@ namespace ROCKY_NAMESPACE bool valid() const; //! Gets a pointer to the underlying image - shared_ptr image() const; + std::shared_ptr image() const; //! Gets the geospatial extent of the image const GeoExtent& extent() const; @@ -123,6 +123,6 @@ namespace ROCKY_NAMESPACE private: GeoExtent _extent; - shared_ptr _image; + std::shared_ptr _image; }; } diff --git a/src/rocky/Geoid.cpp b/src/rocky/Geoid.cpp index 9975a406..bca4c885 100644 --- a/src/rocky/Geoid.cpp +++ b/src/rocky/Geoid.cpp @@ -15,7 +15,7 @@ using namespace ROCKY_NAMESPACE; Geoid::Geoid( const std::string& name_, - shared_ptr hf_, + std::shared_ptr hf_, const Units& units_) : name(name_), diff --git a/src/rocky/Geoid.h b/src/rocky/Geoid.h index c991a401..0a507eb6 100644 --- a/src/rocky/Geoid.h +++ b/src/rocky/Geoid.h @@ -21,13 +21,13 @@ namespace ROCKY_NAMESPACE { public: std::string name; - shared_ptr heightfield; + std::shared_ptr heightfield; Units units; //! Construct Geoid( const std::string& name, - shared_ptr hf, + std::shared_ptr hf, const Units& units); //! Queries the geoid for the height offset at the specified geodetic diff --git a/src/rocky/IOTypes.h b/src/rocky/IOTypes.h index b4b8ca88..559dfdb7 100644 --- a/src/rocky/IOTypes.h +++ b/src/rocky/IOTypes.h @@ -30,24 +30,24 @@ namespace ROCKY_NAMESPACE //! Service for reading an image from a URI using ReadImageURIService = std::function< - Result>(const std::string& location, const IOOptions&)>; + Result>(const std::string& location, const IOOptions&)>; //! Service fro reading an image from a stream using ReadImageStreamService = std::function< - Result>(std::istream& stream, std::string contentType, const IOOptions& io)>; + Result>(std::istream& stream, std::string contentType, const IOOptions& io)>; //! Service for writing an image to a stream using WriteImageStreamService = std::function< - Status(shared_ptr image, std::ostream& stream, std::string contentType, const IOOptions& io)>; + Status(std::shared_ptr image, std::ostream& stream, std::string contentType, const IOOptions& io)>; //! Service for caching data using CacheImpl = void*; // todo. - using CacheService = std::function()>; + using CacheService = std::function()>; //! Service for accessing other data class DataInterface { public: - virtual shared_ptr findLayerByName(const std::string& name) const = 0; + virtual std::shared_ptr findLayerByName(const std::string& name) const = 0; }; using DataService = std::function; @@ -67,7 +67,7 @@ namespace ROCKY_NAMESPACE ReadImageStreamService readImageFromStream; WriteImageStreamService writeImageToStream; CacheService cache = nullptr; - shared_ptr contentCache; + std::shared_ptr contentCache; }; /** diff --git a/src/rocky/Image.cpp b/src/rocky/Image.cpp index cd47974b..1aea3cfd 100644 --- a/src/rocky/Image.cpp +++ b/src/rocky/Image.cpp @@ -115,7 +115,7 @@ Image::hasAlphaChannel() const pixelFormat() == R8G8B8A8_UNORM; } -shared_ptr +std::shared_ptr Image::clone() const { ROCKY_SOFT_ASSERT_AND_RETURN(_data, nullptr); diff --git a/src/rocky/ImageLayer.cpp b/src/rocky/ImageLayer.cpp index 68b7da59..b23291d8 100644 --- a/src/rocky/ImageLayer.cpp +++ b/src/rocky/ImageLayer.cpp @@ -202,7 +202,7 @@ ImageLayer::createImageInKeyProfile(const TileKey& key, const IOOptions& io) con return result; } -shared_ptr +std::shared_ptr ImageLayer::assembleImage(const TileKey& key, const IOOptions& io) const { std::shared_ptr output; diff --git a/src/rocky/ImageLayer.h b/src/rocky/ImageLayer.h index 6cb5f306..447da97e 100644 --- a/src/rocky/ImageLayer.h +++ b/src/rocky/ImageLayer.h @@ -68,7 +68,7 @@ namespace ROCKY_NAMESPACE // Fetches multiple images from the TileSource; mosaics/reprojects/crops as necessary, and // returns a single tile. This is called by createImageFromTileSource() if the key profile // doesn't match the layer profile. - shared_ptr assembleImage( + std::shared_ptr assembleImage( const TileKey& key, const IOOptions& io) const; diff --git a/src/rocky/Instance.cpp b/src/rocky/Instance.cpp index 37e79aca..85dbb8b5 100644 --- a/src/rocky/Instance.cpp +++ b/src/rocky/Instance.cpp @@ -53,7 +53,7 @@ std::unordered_map& Instance::objectFactor } // static object creation function: -shared_ptr +std::shared_ptr Instance::createObjectImpl(const std::string& name, const std::string& JSON, const IOOptions& io) { auto i = objectFactories().find(util::toLower(name)); diff --git a/src/rocky/Instance.h b/src/rocky/Instance.h index cdaeede4..6d1033b0 100644 --- a/src/rocky/Instance.h +++ b/src/rocky/Instance.h @@ -36,11 +36,11 @@ namespace ROCKY_NAMESPACE //! Typical use is for deserializing polymorphic objects from JSON, like //! map layers. using ObjectFactory = std::function< - shared_ptr(const std::string& JSON, const IOOptions& io)>; + std::shared_ptr(const std::string& JSON, const IOOptions& io)>; //! Create an object based on a name and a JSON-serialized configuration template - static shared_ptr createObject(const std::string& name, const std::string& JSON, const IOOptions& io) { + static std::shared_ptr createObject(const std::string& name, const std::string& JSON, const IOOptions& io) { return std::dynamic_pointer_cast(createObjectImpl(name, JSON, io)); } @@ -56,7 +56,7 @@ namespace ROCKY_NAMESPACE std::shared_ptr _impl; static Status _global_status; - static shared_ptr createObjectImpl(const std::string& name, const std::string& JSON, const IOOptions& io); + static std::shared_ptr createObjectImpl(const std::string& name, const std::string& JSON, const IOOptions& io); }; } diff --git a/src/rocky/Layer.h b/src/rocky/Layer.h index 491de2b4..d3252125 100644 --- a/src/rocky/Layer.h +++ b/src/rocky/Layer.h @@ -77,10 +77,10 @@ namespace ROCKY_NAMESPACE virtual DateTimeExtent dateTimeExtent() const; //! Register a callback for layer open - Callback)> onLayerOpened; + Callback)> onLayerOpened; //! Register a callback for layer close - Callback)> onLayerClosed; + Callback)> onLayerClosed; void removeCallback(UID); diff --git a/src/rocky/LayerCollection.cpp b/src/rocky/LayerCollection.cpp index eb4c5c66..68029344 100644 --- a/src/rocky/LayerCollection.cpp +++ b/src/rocky/LayerCollection.cpp @@ -18,13 +18,13 @@ LayerCollection::LayerCollection(Map* map) : } Status -LayerCollection::add(shared_ptr layer) +LayerCollection::add(std::shared_ptr layer) { return add(layer, _map->_instance.io()); } Status -LayerCollection::add(shared_ptr layer, const IOOptions& io) +LayerCollection::add(std::shared_ptr layer, const IOOptions& io) { // check if it's already in the collection if (indexOf(layer) != size()) @@ -57,7 +57,7 @@ LayerCollection::add(shared_ptr layer, const IOOptions& io) } void -LayerCollection::remove(shared_ptr layer) +LayerCollection::remove(std::shared_ptr layer) { if (layer == nullptr) return; @@ -67,7 +67,7 @@ LayerCollection::remove(shared_ptr layer) return; unsigned int index = -1; - shared_ptr layerToRemove(layer); + std::shared_ptr layerToRemove(layer); Revision new_revision = -1; // Close the layer when we remove it from the map. @@ -99,7 +99,7 @@ LayerCollection::remove(shared_ptr layer) } void -LayerCollection::move(shared_ptr layer, unsigned new_index) +LayerCollection::move(std::shared_ptr layer, unsigned new_index) { unsigned oldIndex = 0; unsigned actualIndex = 0; @@ -146,7 +146,7 @@ LayerCollection::size() const } unsigned -LayerCollection::indexOf(shared_ptr layer) const +LayerCollection::indexOf(std::shared_ptr layer) const { if (!layer) return (unsigned)size(); @@ -161,14 +161,14 @@ LayerCollection::indexOf(shared_ptr layer) const return index; } -shared_ptr +std::shared_ptr LayerCollection::_at(unsigned index) const { std::shared_lock lock(_map->_mapDataMutex); return index < _layers.size() ? _layers[index] : nullptr; } -shared_ptr +std::shared_ptr LayerCollection::_withName(const std::string& name) const { std::shared_lock lock(_map->_mapDataMutex); @@ -178,7 +178,7 @@ LayerCollection::_withName(const std::string& name) const return nullptr; } -shared_ptr +std::shared_ptr LayerCollection::_withUID(const UID& uid) const { std::shared_lock lock(_map->_mapDataMutex); @@ -188,7 +188,7 @@ LayerCollection::_withUID(const UID& uid) const return nullptr; } -std::vector> +std::vector> LayerCollection::all() const { std::shared_lock lock(_map->_mapDataMutex); diff --git a/src/rocky/LayerCollection.h b/src/rocky/LayerCollection.h index b5516d5c..6e61c65a 100644 --- a/src/rocky/LayerCollection.h +++ b/src/rocky/LayerCollection.h @@ -20,16 +20,16 @@ namespace ROCKY_NAMESPACE { public: //! Add a layer - Status add(shared_ptr layer); + Status add(std::shared_ptr layer); //! Add a layer with some options - Status add(shared_ptr layer, const IOOptions& io); + Status add(std::shared_ptr layer, const IOOptions& io); //! Remove a layer - void remove(shared_ptr layer); + void remove(std::shared_ptr layer); //! Re-order a layer, placing it at a new index - void move(shared_ptr layer, unsigned index); + void move(std::shared_ptr layer, unsigned index); //! Number of layers in the map std::size_t size() const; @@ -38,28 +38,28 @@ namespace ROCKY_NAMESPACE bool empty() const { return size() == 0; } //! Vector (snapshot in time) of all layers - std::vector> all() const; + std::vector> all() const; //! Index of a specific layer - unsigned indexOf(shared_ptr layer) const; + unsigned indexOf(std::shared_ptr layer) const; //! Layer at the specified index - template inline shared_ptr at(unsigned index) const; + template inline std::shared_ptr at(unsigned index) const; //! Layer with the given name - template inline shared_ptr withName(const std::string& name) const; + template inline std::shared_ptr withName(const std::string& name) const; //! Layer with the given unique ID - template inline shared_ptr withUID(const UID& uid) const; + template inline std::shared_ptr withUID(const UID& uid) const; //! First layer in the list of the template type - template inline shared_ptr firstOfType() const; + template inline std::shared_ptr firstOfType() const; //! A vector of all layers of the templated type - template inline std::vector> ofType() const; + template inline std::vector> ofType() const; - //! Vector of all layers that pass the functor (signature takes a shared_ptr) - template inline std::vector> get(FUNC func) const; + //! Vector of all layers that pass the functor (signature takes a std::shared_ptr) + template inline std::vector> get(FUNC func) const; public: // public properties @@ -73,38 +73,38 @@ namespace ROCKY_NAMESPACE friend class Map; LayerCollection(Map* map); inline LayerCollection(const LayerCollection&) = delete; - std::vector> _layers; - shared_ptr _at(unsigned index) const; - shared_ptr _withName(const std::string& name) const; - shared_ptr _withUID(const UID& uid) const; + std::vector> _layers; + std::shared_ptr _at(unsigned index) const; + std::shared_ptr _withName(const std::string& name) const; + std::shared_ptr _withUID(const UID& uid) const; Map* _map; std::shared_mutex& _map_mutex; }; - template shared_ptr LayerCollection::at(unsigned index) const { + template std::shared_ptr LayerCollection::at(unsigned index) const { return L::cast(_at(index)); } - template shared_ptr LayerCollection::withName(const std::string& name) const { + template std::shared_ptr LayerCollection::withName(const std::string& name) const { return L::cast(_withName(name)); } - template shared_ptr LayerCollection::withUID(const UID& uid) const { + template std::shared_ptr LayerCollection::withUID(const UID& uid) const { return L::cast(_withUID(uid)); } - template shared_ptr LayerCollection::firstOfType() const { + template std::shared_ptr LayerCollection::firstOfType() const { std::shared_lock lock(_map_mutex); for (auto& layer : _layers) { - shared_ptr r = L::cast(layer); + std::shared_ptr r = L::cast(layer); if (r) return r; } return nullptr; } - template std::vector> LayerCollection::ofType() const { - std::vector> output; + template std::vector> LayerCollection::ofType() const { + std::vector> output; std::shared_lock lock(_map_mutex); for (auto& layer : _layers) { auto r = L::cast(layer); @@ -113,8 +113,8 @@ namespace ROCKY_NAMESPACE return output; } - template std::vector> LayerCollection::get(FUNC func) const { - std::vector> output; + template std::vector> LayerCollection::get(FUNC func) const { + std::vector> output; std::shared_lock lock(_map_mutex); for (auto& layer : _layers) { if (func(layer)) diff --git a/src/rocky/LayerReference.h b/src/rocky/LayerReference.h index 61c4ed59..1a22d493 100644 --- a/src/rocky/LayerReference.h +++ b/src/rocky/LayerReference.h @@ -34,13 +34,13 @@ namespace ROCKY_NAMESPACE //! User can call this to set the layer by hand (instead of finding it //! in the map or in an embedded options structure) - void setLayer(shared_ptr layer) + void setLayer(std::shared_ptr layer) { _layer = layer; } //! Contained layer object - shared_ptr getLayer() const + std::shared_ptr getLayer() const { return _layer; } @@ -60,8 +60,8 @@ namespace ROCKY_NAMESPACE { if (_embeddedOptions.has_value()) { - shared_ptr layer = Layer::create(_embeddedOptions.get()); - shared_ptr typedLayer = std::dynamic_pointer_cast(layer); + auto layer = Layer::create(_embeddedOptions.get()); + std::shared_ptr typedLayer = std::dynamic_pointer_cast(layer); if (typedLayer) { const Status& layerStatus = typedLayer->open(io); @@ -93,7 +93,7 @@ namespace ROCKY_NAMESPACE { if (!getLayer() && _externalLayerName.has_value()) { - shared_ptr = map->getLayerByName(_externalLayerName.get()); + auto layer = map->getLayerByName(_externalLayerName.get()); if (layer) { _layer = layer; @@ -111,7 +111,7 @@ namespace ROCKY_NAMESPACE } //! If this reference was set by findInMap, release it. - void removedFromMap(shared_ptr map) + void removedFromMap(std::shared_ptr map) { if (map && _layer) { @@ -152,7 +152,7 @@ namespace ROCKY_NAMESPACE { for(auto& conf : conf.children()) { - shared_ptr layer = Layer::create(conf); + std::shared_ptr layer = Layer::create(conf); if (layer && std::dynamic_pointer_cast(layer)) { _embeddedOptions = TypedOptions(conf); @@ -188,7 +188,7 @@ namespace ROCKY_NAMESPACE private: - shared_ptr _layer; + std::shared_ptr _layer; optional _embeddedOptions; optional _externalLayerName; }; diff --git a/src/rocky/MBTiles.cpp b/src/rocky/MBTiles.cpp index 2798b1b5..8e2ff748 100644 --- a/src/rocky/MBTiles.cpp +++ b/src/rocky/MBTiles.cpp @@ -287,7 +287,7 @@ MBTiles::Driver::readMaxLevel() return result; } -Result> +Result> MBTiles::Driver::read(const TileKey& key, const IOOptions& io) const { std::scoped_lock lock(_mutex); @@ -328,7 +328,7 @@ MBTiles::Driver::read(const TileKey& key, const IOOptions& io) const sqlite3_bind_int(select, 2, x); sqlite3_bind_int(select, 3, y); - Result> result; + Result> result; std::string errorMessage; rc = sqlite3_step(select); @@ -379,7 +379,7 @@ MBTiles::Driver::read(const TileKey& key, const IOOptions& io) const Status -MBTiles::Driver::write(const TileKey& key, shared_ptr input, const IOOptions& io) const +MBTiles::Driver::write(const TileKey& key, std::shared_ptr input, const IOOptions& io) const { if (!key.valid() || !input) return Status(Status::AssertionFailure); diff --git a/src/rocky/MBTiles.h b/src/rocky/MBTiles.h index 7554d55e..66cf66a1 100644 --- a/src/rocky/MBTiles.h +++ b/src/rocky/MBTiles.h @@ -46,13 +46,13 @@ namespace ROCKY_NAMESPACE void close(); - Result> read( + Result> read( const TileKey& key, const IOOptions& io) const; Status write( const TileKey& key, - shared_ptr image, + std::shared_ptr image, const IOOptions& io) const; void setDataExtents(const DataExtentList&); @@ -63,7 +63,7 @@ namespace ROCKY_NAMESPACE void* _database; mutable unsigned _minLevel; mutable unsigned _maxLevel; - shared_ptr _emptyImage; + std::shared_ptr _emptyImage; Options _options; std::string _tileFormat; bool _forceRGB; diff --git a/src/rocky/Map.h b/src/rocky/Map.h index 8e433cfb..531820d3 100644 --- a/src/rocky/Map.h +++ b/src/rocky/Map.h @@ -82,15 +82,15 @@ namespace ROCKY_NAMESPACE public: //! Callback fired upon added a layer - using LayerAdded = void(shared_ptr, unsigned index, Revision); + using LayerAdded = void(std::shared_ptr, unsigned index, Revision); Callback onLayerAdded; //! Callback fired upon removing a layer - using LayerRemoved = void(shared_ptr, Revision); + using LayerRemoved = void(std::shared_ptr, Revision); Callback onLayerRemoved; //! Callback fired upon reordering a layer - using LayerMoved = void(shared_ptr, unsigned oldIndex, unsigned newIndex, Revision); + using LayerMoved = void(std::shared_ptr, unsigned oldIndex, unsigned newIndex, Revision); Callback onLayerMoved; //! Remove a callback added to thie object @@ -102,7 +102,7 @@ namespace ROCKY_NAMESPACE private: Instance _instance; UID _uid; - std::vector> _layers; + std::vector> _layers; mutable std::shared_mutex _mapDataMutex; optional _profile; Revision _dataModelRevision; diff --git a/src/rocky/Profile.h b/src/rocky/Profile.h index a8d9f4ff..dab8f393 100644 --- a/src/rocky/Profile.h +++ b/src/rocky/Profile.h @@ -188,7 +188,7 @@ namespace ROCKY_NAMESPACE std::string _horizSignature; std::size_t _hash; }; - shared_ptr _shared; + std::shared_ptr _shared; }; diff --git a/src/rocky/SRS.cpp b/src/rocky/SRS.cpp index 78760694..8822351b 100644 --- a/src/rocky/SRS.cpp +++ b/src/rocky/SRS.cpp @@ -121,7 +121,7 @@ namespace if (ndef == "wgs84" || ndef == "global-geodetic") to_try = "epsg:4979"; else if (ndef == "spherical-mercator") - to_try = "epsg:3785"; + to_try = "epsg:3857"; //3785; else if (ndef == "geocentric" || ndef == "ecef") to_try = "epsg:4978"; else if (ndef == "plate-carree" || ndef == "plate-carre") diff --git a/src/rocky/TMS.cpp b/src/rocky/TMS.cpp index 5f078008..30d2cc55 100644 --- a/src/rocky/TMS.cpp +++ b/src/rocky/TMS.cpp @@ -686,10 +686,10 @@ TMS::Driver::open(const URI& uri, Profile& profile, const std::string& format, D return StatusOK; } -Result> +Result> TMS::Driver::read(const TileKey& key, bool invertY, bool isMapboxRGB, const URIContext& context, const IOOptions& io) const { - shared_ptr image; + std::shared_ptr image; URI imageURI; // create the URI from the tile map? diff --git a/src/rocky/TMS.h b/src/rocky/TMS.h index 45b7c20e..b9cc954e 100644 --- a/src/rocky/TMS.h +++ b/src/rocky/TMS.h @@ -122,7 +122,7 @@ namespace ROCKY_NAMESPACE void close(); - Result> read( + Result> read( const TileKey& key, bool invertY, bool isMapboxRGB, diff --git a/src/rocky/TerrainTileModel.h b/src/rocky/TerrainTileModel.h index 07f6e6aa..727200be 100644 --- a/src/rocky/TerrainTileModel.h +++ b/src/rocky/TerrainTileModel.h @@ -32,7 +32,7 @@ namespace ROCKY_NAMESPACE CreateTileManifest(); //! Request data for a layer - void insert(shared_ptr layer); + void insert(std::shared_ptr layer); //! Sets whether to apply the update progressively (in LOD order) void setProgressive(bool value); @@ -79,7 +79,7 @@ namespace ROCKY_NAMESPACE struct ROCKY_EXPORT ColorLayer : public Tile { GeoImage image; - shared_ptr layer; + std::shared_ptr layer; using Vector = std::vector; }; @@ -93,7 +93,7 @@ namespace ROCKY_NAMESPACE struct ROCKY_EXPORT NormalMap : public Tile { GeoImage image; - shared_ptr layer; + std::shared_ptr layer; }; struct ROCKY_EXPORT MaterialMap : public Tile diff --git a/src/rocky/TerrainTileModelFactory.cpp b/src/rocky/TerrainTileModelFactory.cpp index ffd532a3..d2eef151 100644 --- a/src/rocky/TerrainTileModelFactory.cpp +++ b/src/rocky/TerrainTileModelFactory.cpp @@ -41,7 +41,7 @@ CreateTileManifest::CreateTileManifest() } void -CreateTileManifest::insert(shared_ptr layer) +CreateTileManifest::insert(std::shared_ptr layer) { if (layer) { @@ -212,7 +212,7 @@ TerrainTileModelFactory::addColorLayers( int order = 0; // fetch the candidate layers: - auto layers = map->layers().get([&manifest](const shared_ptr& layer) + auto layers = map->layers().get([&manifest](const std::shared_ptr& layer) { return layer->isOpen() && diff --git a/src/rocky/Threading.h b/src/rocky/Threading.h index 91a49145..a8cccc4d 100644 --- a/src/rocky/Threading.h +++ b/src/rocky/Threading.h @@ -7,11 +7,11 @@ #include #include #include +#include namespace ROCKY_NAMESPACE { using Cancelable = WEEJOBS_NAMESPACE::cancelable; - //template using Future = WEEJOBS_NAMESPACE::future; namespace util { @@ -28,8 +28,7 @@ namespace ROCKY_NAMESPACE for(auto& p : _data) if (p.first == id) return p.second; - _data.emplace_back(id, T()); - return _data.back().second; + return _data.emplace_back(id, T()).second; } void clear() { @@ -39,7 +38,7 @@ namespace ROCKY_NAMESPACE private: std::mutex _mutex; - std::vector> _data; + std::list> _data; }; /** Primitive that only allows one thread at a time access to a keyed resourse */ diff --git a/src/rocky/URI.cpp b/src/rocky/URI.cpp index c524d368..8c322605 100644 --- a/src/rocky/URI.cpp +++ b/src/rocky/URI.cpp @@ -434,7 +434,7 @@ namespace //------------------------------------------------------------------------ -URI::Stream::Stream(shared_ptr s) : +URI::Stream::Stream(std::shared_ptr s) : _in(s) { //nop diff --git a/src/rocky/URI.h b/src/rocky/URI.h index 5de41665..be05b929 100644 --- a/src/rocky/URI.h +++ b/src/rocky/URI.h @@ -53,7 +53,7 @@ namespace ROCKY_NAMESPACE struct ROCKY_EXPORT Stream { public: - Stream(shared_ptr s = nullptr); + Stream(std::shared_ptr s = nullptr); //! Whether the stream exists bool valid() const { return _in != nullptr; } @@ -65,7 +65,7 @@ namespace ROCKY_NAMESPACE std::string to_string(); private: - shared_ptr _in; + std::shared_ptr _in; }; public: diff --git a/src/rocky/vsg/ECS.h b/src/rocky/vsg/ECS.h index cd363f6a..3b2f7a86 100644 --- a/src/rocky/vsg/ECS.h +++ b/src/rocky/vsg/ECS.h @@ -118,9 +118,6 @@ namespace ROCKY_NAMESPACE //! Attach point for additional components, as needed entt::entity attach_point = entt::null; - - protected: - RevisionedComponent() = default; }; /** diff --git a/src/rocky/vsg/InstanceVSG.cpp b/src/rocky/vsg/InstanceVSG.cpp index 307958ad..395fa62e 100644 --- a/src/rocky/vsg/InstanceVSG.cpp +++ b/src/rocky/vsg/InstanceVSG.cpp @@ -355,7 +355,7 @@ InstanceVSG::ctor(int& argc, char** argv) // To read from a stream, we have to search all the VS readerwriters to // find one that matches the 'extension' we want. We also have to put that // extension in the options structure as a hint. - io().services.readImageFromStream = [options(runtime.readerWriterOptions)](std::istream& location, std::string contentType, const rocky::IOOptions& io) -> Result> + io().services.readImageFromStream = [options(runtime.readerWriterOptions)](std::istream& location, std::string contentType, const rocky::IOOptions& io) -> Result> { // try the mime-type mapping: auto i = ext_for_mime_type.find(contentType); diff --git a/src/rocky/vsg/MapManipulator.cpp b/src/rocky/vsg/MapManipulator.cpp index a0d359be..07406c8f 100644 --- a/src/rocky/vsg/MapManipulator.cpp +++ b/src/rocky/vsg/MapManipulator.cpp @@ -621,7 +621,7 @@ MapManipulator::configureDefaultSettings() } void -MapManipulator::applySettings(shared_ptr settings) +MapManipulator::applySettings(std::shared_ptr settings) { if ( settings ) { @@ -655,7 +655,7 @@ MapManipulator::applySettings(shared_ptr settings) #endif } -shared_ptr +std::shared_ptr MapManipulator::getSettings() const { return _settings; diff --git a/src/rocky/vsg/MapManipulator.h b/src/rocky/vsg/MapManipulator.h index 7190994e..058e0372 100644 --- a/src/rocky/vsg/MapManipulator.h +++ b/src/rocky/vsg/MapManipulator.h @@ -598,11 +598,11 @@ namespace ROCKY_NAMESPACE bool _zoomToMouse; }; - shared_ptr _settings; + std::shared_ptr _settings; - void applySettings(shared_ptr); + void applySettings(std::shared_ptr); - shared_ptr getSettings() const; + std::shared_ptr getSettings() const; protected: diff --git a/src/rocky/vsg/MapNode.cpp b/src/rocky/vsg/MapNode.cpp index e5e7adf5..802026dd 100644 --- a/src/rocky/vsg/MapNode.cpp +++ b/src/rocky/vsg/MapNode.cpp @@ -27,7 +27,7 @@ MapNode::MapNode(const InstanceVSG& instance) : construct(); } -MapNode::MapNode(shared_ptr in_map) : +MapNode::MapNode(std::shared_ptr in_map) : instance(reinterpret_cast(in_map->instance())), map(in_map) { diff --git a/src/rocky/vsg/MapNode.h b/src/rocky/vsg/MapNode.h index 306dfb59..97b302af 100644 --- a/src/rocky/vsg/MapNode.h +++ b/src/rocky/vsg/MapNode.h @@ -30,7 +30,7 @@ namespace ROCKY_NAMESPACE MapNode(const InstanceVSG& instance); //! Creates a map node that will render the given Map. - MapNode(shared_ptr map); + MapNode(std::shared_ptr map); //! Deserialize a MapNode explicit MapNode(const JSON& conf, const InstanceVSG& instance); diff --git a/src/rocky/vsg/engine/SurfaceNode.cpp b/src/rocky/vsg/engine/SurfaceNode.cpp index 8f0c8f5d..89d8a00c 100644 --- a/src/rocky/vsg/engine/SurfaceNode.cpp +++ b/src/rocky/vsg/engine/SurfaceNode.cpp @@ -39,7 +39,7 @@ SurfaceNode::SurfaceNode(const TileKey& tilekey, const SRS& worldSRS, Runtime& r } void -SurfaceNode::setElevation(shared_ptr raster, const glm::dmat4& scaleBias) +SurfaceNode::setElevation(std::shared_ptr raster, const glm::dmat4& scaleBias) { _elevationRaster = raster; _elevationMatrix = scaleBias; diff --git a/src/rocky/vsg/engine/SurfaceNode.h b/src/rocky/vsg/engine/SurfaceNode.h index cac4cf5e..c75c8707 100644 --- a/src/rocky/vsg/engine/SurfaceNode.h +++ b/src/rocky/vsg/engine/SurfaceNode.h @@ -34,11 +34,11 @@ namespace ROCKY_NAMESPACE //! Update the elevation raster associated with this tile void setElevation( - shared_ptr raster, + std::shared_ptr raster, const glm::dmat4& scaleBias); //! Elevation raster representing this surface - shared_ptr getElevationRaster() const { + std::shared_ptr getElevationRaster() const { return _elevationRaster; } @@ -61,7 +61,7 @@ namespace ROCKY_NAMESPACE TileKey _tileKey; int _lastFramePassedCull = 0; - shared_ptr _elevationRaster; + std::shared_ptr _elevationRaster; glm::dmat4 _elevationMatrix; std::vector _worldPoints; bool _boundsDirty = true; diff --git a/src/rocky/vsg/engine/TerrainEngine.cpp b/src/rocky/vsg/engine/TerrainEngine.cpp index b28a8fd8..7d8776d1 100644 --- a/src/rocky/vsg/engine/TerrainEngine.cpp +++ b/src/rocky/vsg/engine/TerrainEngine.cpp @@ -15,7 +15,7 @@ using namespace ROCKY_NAMESPACE; TerrainEngine::TerrainEngine( - shared_ptr new_map, + std::shared_ptr new_map, const SRS& new_worldSRS, Runtime& new_runtime, const TerrainSettings& new_settings, diff --git a/src/rocky/vsg/engine/TerrainEngine.h b/src/rocky/vsg/engine/TerrainEngine.h index 8f3fc51d..0189cac3 100644 --- a/src/rocky/vsg/engine/TerrainEngine.h +++ b/src/rocky/vsg/engine/TerrainEngine.h @@ -25,7 +25,7 @@ namespace ROCKY_NAMESPACE { public: TerrainEngine( - shared_ptr map, + std::shared_ptr map, const SRS& worldSRS, Runtime& runtime, const TerrainSettings& settings, @@ -38,7 +38,7 @@ namespace ROCKY_NAMESPACE Runtime& runtime; //! the map this terrain is rendering - shared_ptr map; + std::shared_ptr map; //! SRS of the rendered terrain SRS worldSRS; diff --git a/src/rocky/vsg/engine/TerrainNode.cpp b/src/rocky/vsg/engine/TerrainNode.cpp index 706cf450..43dedc73 100644 --- a/src/rocky/vsg/engine/TerrainNode.cpp +++ b/src/rocky/vsg/engine/TerrainNode.cpp @@ -46,7 +46,7 @@ TerrainNode::to_json() const } const Status& -TerrainNode::setMap(shared_ptr new_map, const SRS& new_worldSRS) +TerrainNode::setMap(std::shared_ptr new_map, const SRS& new_worldSRS) { ROCKY_SOFT_ASSERT_AND_RETURN(new_map, status); diff --git a/src/rocky/vsg/engine/TerrainNode.h b/src/rocky/vsg/engine/TerrainNode.h index 0a580578..abcaf092 100644 --- a/src/rocky/vsg/engine/TerrainNode.h +++ b/src/rocky/vsg/engine/TerrainNode.h @@ -33,7 +33,7 @@ namespace ROCKY_NAMESPACE TerrainNode(Runtime& runtime); //! Map to render, and SRS to render it in - const Status& setMap(shared_ptr new_map, const SRS& world_srs); + const Status& setMap(std::shared_ptr new_map, const SRS& world_srs); //! Clear out the terrain and rebuild it from the map model void reset(); diff --git a/src/rocky/vsg/engine/TerrainTileNode.cpp b/src/rocky/vsg/engine/TerrainTileNode.cpp index cab998b5..92d50c2c 100644 --- a/src/rocky/vsg/engine/TerrainTileNode.cpp +++ b/src/rocky/vsg/engine/TerrainTileNode.cpp @@ -98,7 +98,7 @@ TerrainTileNode::recomputeBound() } void -TerrainTileNode::setElevation(shared_ptr image, const glm::dmat4& matrix) +TerrainTileNode::setElevation(std::shared_ptr image, const glm::dmat4& matrix) { if (surface) { diff --git a/src/rocky/vsg/engine/TerrainTileNode.h b/src/rocky/vsg/engine/TerrainTileNode.h index d2535277..811d7981 100644 --- a/src/rocky/vsg/engine/TerrainTileNode.h +++ b/src/rocky/vsg/engine/TerrainTileNode.h @@ -33,7 +33,7 @@ namespace ROCKY_NAMESPACE struct TextureData { std::string name; - shared_ptr image; + std::shared_ptr image; glm::dmat4 matrix{ 1 }; }; @@ -125,11 +125,11 @@ namespace ROCKY_NAMESPACE //! Elevation data for this node along with its scale/bias matrix; //! needed for bounding box void setElevation( - shared_ptr image, + std::shared_ptr image, const glm::dmat4& matrix); //! This node's elevation raster image - shared_ptr getElevationRaster() const { + std::shared_ptr getElevationRaster() const { return surface->getElevationRaster(); } diff --git a/src/rocky/vsg/engine/TerrainTilePager.cpp b/src/rocky/vsg/engine/TerrainTilePager.cpp index 11ebb8e8..19719b53 100644 --- a/src/rocky/vsg/engine/TerrainTilePager.cpp +++ b/src/rocky/vsg/engine/TerrainTilePager.cpp @@ -151,7 +151,7 @@ TerrainTilePager::ping(TerrainTileNode* tile, const TerrainTileNode* parent, vsg } bool -TerrainTilePager::update(const vsg::FrameStamp* fs, const IOOptions& io, shared_ptr terrain) +TerrainTilePager::update(const vsg::FrameStamp* fs, const IOOptions& io, std::shared_ptr terrain) { std::scoped_lock lock(_mutex); @@ -283,7 +283,7 @@ TerrainTilePager::update(const vsg::FrameStamp* fs, const IOOptions& io, shared_ } vsg::ref_ptr -TerrainTilePager::createTile(const TileKey& key, vsg::ref_ptr parent, shared_ptr terrain) +TerrainTilePager::createTile(const TileKey& key, vsg::ref_ptr parent, std::shared_ptr terrain) { GeometryPool::Settings geomSettings { @@ -333,7 +333,7 @@ TerrainTilePager::getTile(const TileKey& key) const void TerrainTilePager::requestLoadSubtiles( vsg::ref_ptr parent, - shared_ptr engine) const + std::shared_ptr engine) const { ROCKY_SOFT_ASSERT_AND_RETURN(parent, void()); @@ -402,7 +402,7 @@ void TerrainTilePager::requestLoadData( vsg::ref_ptr tile, const IOOptions& in_io, - shared_ptr engine) const + std::shared_ptr engine) const { ROCKY_SOFT_ASSERT_AND_RETURN(tile, void()); @@ -471,7 +471,7 @@ void TerrainTilePager::requestMergeData( vsg::ref_ptr tile, const IOOptions& in_io, - shared_ptr engine) const + std::shared_ptr engine) const { ROCKY_SOFT_ASSERT_AND_RETURN(tile, void()); @@ -583,7 +583,7 @@ void TerrainTilePager::requestLoadElevation( vsg::ref_ptr tile, const IOOptions& in_io, - shared_ptr engine) const + std::shared_ptr engine) const { #ifdef LOAD_ELEVATION_SEPARATELY ROCKY_SOFT_ASSERT_AND_RETURN(tile, void()); @@ -644,7 +644,7 @@ void TerrainTilePager::requestMergeElevation( vsg::ref_ptr tile, const IOOptions& in_io, - shared_ptr engine) const + std::shared_ptr engine) const { #ifdef LOAD_ELEVATION_SEPARATELY ROCKY_SOFT_ASSERT_AND_RETURN(tile, void()); diff --git a/src/rocky/vsg/engine/TerrainTilePager.h b/src/rocky/vsg/engine/TerrainTilePager.h index c41724ce..4b0f0d7a 100644 --- a/src/rocky/vsg/engine/TerrainTilePager.h +++ b/src/rocky/vsg/engine/TerrainTilePager.h @@ -66,13 +66,13 @@ namespace ROCKY_NAMESPACE bool update( const vsg::FrameStamp* fs, const IOOptions& io, - shared_ptr terrain); + std::shared_ptr terrain); //! Create a single terrain tile. vsg::ref_ptr createTile( const TileKey& key, vsg::ref_ptr parent, - shared_ptr terrain); + std::shared_ptr terrain); //! Fetches a tile by its key. //! @param key TileKey for which to fetch a tile @@ -103,27 +103,27 @@ namespace ROCKY_NAMESPACE void requestLoadSubtiles( vsg::ref_ptr parent, - shared_ptr terrain) const; + std::shared_ptr terrain) const; void requestLoadElevation( vsg::ref_ptr tile, const IOOptions& io, - shared_ptr terrain) const; + std::shared_ptr terrain) const; void requestMergeElevation( vsg::ref_ptr tile, const IOOptions& io, - shared_ptr terrain) const; + std::shared_ptr terrain) const; void requestLoadData( vsg::ref_ptr tile, const IOOptions& io, - shared_ptr terrain) const; + std::shared_ptr terrain) const; void requestMergeData( vsg::ref_ptr tile, const IOOptions& io, - shared_ptr terrain) const; + std::shared_ptr terrain) const; void getRanges( const TileKey& key, diff --git a/src/rocky/vsg/engine/Utils.h b/src/rocky/vsg/engine/Utils.h index 6fa35387..84774cbd 100644 --- a/src/rocky/vsg/engine/Utils.h +++ b/src/rocky/vsg/engine/Utils.h @@ -95,7 +95,7 @@ namespace ROCKY_NAMESPACE namespace util { template - vsg::ref_ptr move(shared_ptr image, VkFormat format) + vsg::ref_ptr move(std::shared_ptr image, VkFormat format) { // NB! // We copy the values out of image FIRST because once we call @@ -137,7 +137,7 @@ namespace ROCKY_NAMESPACE //! Moves a rocky Image object into a VSG Data object. //! The source Image is cleared in the process. - inline vsg::ref_ptr moveImageData(shared_ptr image) + inline vsg::ref_ptr moveImageData(std::shared_ptr image) { if (!image) return { }; @@ -173,7 +173,7 @@ namespace ROCKY_NAMESPACE // take ownership of the input image as a VSG object. // the input image becomes INVALID after this method. If that's not what // you want, clone the input image first! - inline vsg::ref_ptr moveImageToVSG(shared_ptr image) + inline vsg::ref_ptr moveImageToVSG(std::shared_ptr image) { if (!image) return {}; @@ -186,7 +186,7 @@ namespace ROCKY_NAMESPACE } // Convert a vsg::Data structure to an Image if possible - inline Result> makeImageFromVSG(vsg::ref_ptr data) + inline Result> makeImageFromVSG(vsg::ref_ptr data) { if (!data) return Status(Status::ResourceUnavailable, "Data is empty"); diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 91753247..8cd5771c 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -266,19 +266,19 @@ TEST_CASE("Map") unsigned cb_code = 0; - auto added_cb = [&cb_code](shared_ptr layer, unsigned index, Revision rev) + auto added_cb = [&cb_code](std::shared_ptr layer, unsigned index, Revision rev) { cb_code = 100; }; map->onLayerAdded(added_cb); - auto moved_cb = [&cb_code](shared_ptr layer, unsigned oldIndex, unsigned newIndex, Revision rev) + auto moved_cb = [&cb_code](std::shared_ptr layer, unsigned oldIndex, unsigned newIndex, Revision rev) { cb_code = 200; }; map->onLayerMoved(moved_cb); - auto removed_cb = [&cb_code](shared_ptr layer, Revision rev) + auto removed_cb = [&cb_code](std::shared_ptr layer, Revision rev) { cb_code = 300; };