Cache J2000 position over a time range. * * This method will load an internal cache with coordinates over a time * range. This prevents * the NAIF kernels from being read over-and-over again and slowing a * application down due to I/O performance. Once the * cache has been loaded then the kernels can be unloaded from the NAIF * system. * * @param startTime Starting e
| 295 | * |
| 296 | */ |
| 297 | void SpicePosition::LoadCache(double startTime, double endTime, int size) { |
| 298 | // Make sure cache isn't already loaded |
| 299 | if(p_source == Memcache || p_source == HermiteCache) { |
| 300 | QString msg = "A SpicePosition cache has already been created"; |
| 301 | throw IException(IException::Programmer, msg, _FILEINFO_); |
| 302 | } |
| 303 | |
| 304 | if(startTime > endTime) { |
| 305 | QString msg = "Argument startTime must be less than or equal to endTime"; |
| 306 | throw IException(IException::Programmer, msg, _FILEINFO_); |
| 307 | } |
| 308 | |
| 309 | if((startTime != endTime) && (size == 1)) { |
| 310 | QString msg = "Cache size must be more than 1 if startTime endTime differ"; |
| 311 | throw IException(IException::Programmer, msg, _FILEINFO_); |
| 312 | } |
| 313 | |
| 314 | // Save full cache parameters |
| 315 | p_fullCacheStartTime = startTime; |
| 316 | p_fullCacheEndTime = endTime; |
| 317 | p_fullCacheSize = size; |
| 318 | LoadTimeCache(); |
| 319 | |
| 320 | // Loop and load the cache |
| 321 | std::vector<ale::State> stateCache; |
| 322 | for(int i = 0; i < size; i++) { |
| 323 | double et = p_cacheTime[i]; |
| 324 | SetEphemerisTime(et); |
| 325 | ale::State currentState = ale::State(ale::Vec3d(p_coordinate)); |
| 326 | if (p_hasVelocity) { |
| 327 | currentState.velocity = ale::Vec3d(p_velocity); |
| 328 | } |
| 329 | stateCache.push_back(currentState); |
| 330 | } |
| 331 | |
| 332 | if (m_state != NULL) { |
| 333 | delete m_state; |
| 334 | } |
| 335 | |
| 336 | m_state = new ale::States(p_cacheTime, stateCache); |
| 337 | p_source = Memcache; |
| 338 | } |
| 339 | |
| 340 | |
| 341 | /** Cache J2000 position for a time. |