@@ -92,15 +92,15 @@ int RasterContainer::LoadRasterSource(const std::string &path_string,
92
92
const auto _ymin = static_cast <std::int32_t >(util::toFixed (util::FloatLatitude{ymin}));
93
93
const auto _ymax = static_cast <std::int32_t >(util::toFixed (util::FloatLatitude{ymax}));
94
94
95
- const auto itr = LoadedSourcePaths .find (path_string);
96
- if (itr != LoadedSourcePaths .end ())
95
+ const auto itr = RasterCache::getInstance (). getLoadedSourcePaths () .find (path_string);
96
+ if (itr != RasterCache::getInstance (). getLoadedSourcePaths () .end ())
97
97
{
98
98
util::Log () << " [source loader] Already loaded source '" << path_string << " ' at source_id "
99
99
<< itr->second ;
100
100
return itr->second ;
101
101
}
102
102
103
- int source_id = static_cast <int >(LoadedSources .size ());
103
+ int source_id = static_cast <int >(RasterCache::getInstance (). getLoadedSources () .size ());
104
104
105
105
util::Log () << " [source loader] Loading from " << path_string << " ... " ;
106
106
TIMER_START (loading_source);
@@ -116,8 +116,8 @@ int RasterContainer::LoadRasterSource(const std::string &path_string,
116
116
117
117
RasterSource source{std::move (rasterData), ncols, nrows, _xmin, _xmax, _ymin, _ymax};
118
118
TIMER_STOP (loading_source);
119
- LoadedSourcePaths .emplace (path_string, source_id);
120
- LoadedSources .push_back (std::move (source));
119
+ RasterCache::getInstance (). getLoadedSourcePaths () .emplace (path_string, source_id);
120
+ RasterCache::getInstance (). getLoadedSources () .push_back (std::move (source));
121
121
122
122
util::Log () << " [source loader] ok, after " << TIMER_SEC (loading_source) << " s" ;
123
123
@@ -127,10 +127,11 @@ int RasterContainer::LoadRasterSource(const std::string &path_string,
127
127
// External function for looking up nearest data point from a specified source
128
128
RasterDatum RasterContainer::GetRasterDataFromSource (unsigned int source_id, double lon, double lat)
129
129
{
130
- if (LoadedSources .size () < source_id + 1 )
130
+ if (RasterCache::getInstance (). getLoadedSources () .size () < source_id + 1 )
131
131
{
132
132
throw util::exception (" Attempted to access source " + std::to_string (source_id) +
133
- " , but there are only " + std::to_string (LoadedSources.size ()) +
133
+ " , but there are only " +
134
+ std::to_string (RasterCache::getInstance ().getLoadedSources ().size ()) +
134
135
" loaded" + SOURCE_REF);
135
136
}
136
137
@@ -139,7 +140,7 @@ RasterDatum RasterContainer::GetRasterDataFromSource(unsigned int source_id, dou
139
140
BOOST_ASSERT (lon < 180 );
140
141
BOOST_ASSERT (lon > -180 );
141
142
142
- const auto &found = LoadedSources [source_id];
143
+ const auto &found = RasterCache::getInstance (). getLoadedSources () [source_id];
143
144
return found.GetRasterData (static_cast <std::int32_t >(util::toFixed (util::FloatLongitude{lon})),
144
145
static_cast <std::int32_t >(util::toFixed (util::FloatLatitude{lat})));
145
146
}
@@ -148,10 +149,11 @@ RasterDatum RasterContainer::GetRasterDataFromSource(unsigned int source_id, dou
148
149
RasterDatum
149
150
RasterContainer::GetRasterInterpolateFromSource (unsigned int source_id, double lon, double lat)
150
151
{
151
- if (LoadedSources .size () < source_id + 1 )
152
+ if (RasterCache::getInstance (). getLoadedSources () .size () < source_id + 1 )
152
153
{
153
154
throw util::exception (" Attempted to access source " + std::to_string (source_id) +
154
- " , but there are only " + std::to_string (LoadedSources.size ()) +
155
+ " , but there are only " +
156
+ std::to_string (RasterCache::getInstance ().getLoadedSources ().size ()) +
155
157
" loaded" + SOURCE_REF);
156
158
}
157
159
@@ -160,10 +162,12 @@ RasterContainer::GetRasterInterpolateFromSource(unsigned int source_id, double l
160
162
BOOST_ASSERT (lon < 180 );
161
163
BOOST_ASSERT (lon > -180 );
162
164
163
- const auto &found = LoadedSources [source_id];
165
+ const auto &found = RasterCache::getInstance (). getLoadedSources () [source_id];
164
166
return found.GetRasterInterpolate (
165
167
static_cast <std::int32_t >(util::toFixed (util::FloatLongitude{lon})),
166
168
static_cast <std::int32_t >(util::toFixed (util::FloatLatitude{lat})));
167
169
}
170
+
171
+ RasterCache *RasterCache::g_instance = NULL ;
168
172
}
169
173
}
0 commit comments