void FeltGridDefinition::geographicProj( int gridType, float startLongitude, float startLatitude, float iInc, float jInc, const std::vector<short int> & extraData) { FeltFile::log("FeltGridDefinition: Geographic projection identified in FELT file"); const int gsSize = 6; float scale = 10000.0; if ( extraData.empty() ) { gridPars_[0] = startLongitude; gridPars_[1] = startLatitude; gridPars_[2] = iInc; gridPars_[3] = jInc; gridPars_[4] = 0.0; gridPars_[5] = 0.0; } else if ( extraData.size() == gsSize * 2 ) { for(int i = 0;i < gsSize;i++) gridPars_[i] = static_cast<float>((extraData[i * 2] * scale) + extraData[(i * 2) + 1]) / scale; } else if ( extraData.size() == 2 + (gsSize * 3) ) { if(extraData[0] != gsSize) throw std::runtime_error("First word in the grid encoding does not correspond to the gridspec size"); if(extraData[1] != 3) throw std::runtime_error("Second word in the grid encoding does not correspond to 3 (rotated grid)"); for(int i = 0;i < gsSize;i++) gridPars_[i] = static_cast<float>((extraData[(i * 3) + 3] * scale) + extraData[(i * 3) + 4]) / (extraData[(i * 3) + 2] * 10.0); } else throw std::runtime_error("The encoded grid specification in the FELT file is not supported"); if (FeltFile::isLogging()) { std::ostringstream buffer; buffer << "FeltGridDefinition: " << std::endl; buffer << "Grid Specification: " << gridPars_[0] << " | " << gridPars_[1] << " | " << gridPars_[2] << " | " << gridPars_[3] << " | " << gridPars_[4] << " | " << gridPars_[5] << std::endl; buffer << "Grid Type: " << gridType << std::endl; FeltFile::log(buffer.str()); } if (FeltFile::isLogging()) FeltFile::log("FeltGridDefinition: Proj Specification: " + gridParametersToProjDefinition(gridType, gridPars_)); orientation_ = getScanMode(); incrementX_ = gridPars_[2]; incrementY_ = gridPars_[3]; startX_ = gridPars_[0]; startY_= gridPars_[1]; }
//------------------------------------------------------------------------------ // scanController() -- control the gimbal's scanning //------------------------------------------------------------------------------ void ScanGimbal::scanController(const double dt) { switch (getScanMode()) { case CONICAL_SCAN : { conicalScanController(dt); break; } case CIRCULAR_SCAN : { circularScanController(dt); break; } case MANUAL_SCAN : { manualScanController(dt); break; } case PSEUDO_RANDOM_SCAN : { pseudoRandomScanController(dt); break; } case SPIRAL_SCAN : { spiralScanController(dt); break; } case HORIZONTAL_BAR_SCAN : case VERTICAL_BAR_SCAN : { barScanController(dt); break; } default : { userModesScanController(dt); break; } }; }
//------------------------------------------------------------------------------ // computeNewBarPos() - computes the beginning or end point of the bar to be scanned //------------------------------------------------------------------------------ void ScanGimbal::computeNewBarPos(const int bar, const Side side) { // Lookup tables // 1 bar scan static double table1[2][2] = { { -1, 0 }, { 1, 0 } }; // 2 bar scan static double table2[2][2][2] = { { {-1, 0.5f}, {1, 0.5f} }, { {1, -0.5f}, {-1, -0.5f} } }; // 3 bar scan static double table3[3][2][2] = { { { -1, 1 }, { 1, 1 } }, { { 1, 0 }, { -1, 0 } }, { { -1, -1 }, { 1 , -1 } } }; // 4 bar scan static double table4[4][2][2] = { { { -1, 1.5f}, { 1, 1.5f} }, { { 1, 0.5f}, { -1, 0.5f} }, { { -1, -0.5f}, { 1, -0.5f} }, { { 1, -1.5f}, { -1, -1.5f} } }; // Now we determine which table to use, depending on the number of bars double x = 0.0; double y = 0.0; // now we draw the Unitless numbers from the tables unsigned int nb = getNumBars(); if (nb == 1) { x = table1[side][0]; y = table1[side][1]; } else if (nb == 2) { x = table2[bar-1][side][0]; y = table2[bar-1][side][1]; } else if (nb == 3) { x = table3[bar-1][side][0]; y = table3[bar-1][side][1]; } else if (nb == 4) { x = table4[bar-1][side][0]; y = table4[bar-1][side][1]; } // swap x values if we are scanning right to left if (!isLeftToRightScan()) x = -x; // if we have an odd number of bars and are in the reverse scan sequence swap // x values on even bar numbers or on bar if only a 1 bar scan if (nb == 1 && isReverseScan()) { x = -x; } // now turn our Unitless numbers in something we can use double x1 = x * (0.5 * getScanWidth()); double y1 = y * (getBarSpacing()); // We need to find which mode we are in before computing the start position if (getScanMode() == HORIZONTAL_BAR_SCAN) { setScanPos(x1, y1); } else { setScanPos(y1, x1); } }