Exemplo n.º 1
0
const utility::file::path::component maildirUtils::buildFilename
(const utility::file::path::component& id, const int flags)
{
    if (flags == message::FLAG_RECENT)
        return id;
    else
        return (buildFilename(id, buildFlags(flags)));
}
Exemplo n.º 2
0
void MainWindow::doCliwocConverter()
{
    int		i				= 0;
    int		err				= 0;
    int		stopProgress	= 0;

    QString s_FilenameIn    = "";
    QString s_FilenameOut   = "";
    QString s_FilenameConf  = "";

// **********************************************************************************************

    if ( existsFirstFile( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList ) == true )
    {
        QFileInfo fi( gsl_FilenameList.at( 0 ) );

        s_FilenameConf = QFileDialog::getOpenFileName( this, tr( "Choose parameter config file" ), fi.absolutePath() + tr( "/Parameter.conf" ), tr( "Config (*.conf)" ) );

        if ( s_FilenameConf.isEmpty() == false )
        {
            initFileProgress( gsl_FilenameList.count(), gsl_FilenameList.at( 0 ), tr( "CLIWOC converter working..." ) );

            while ( ( i < gsl_FilenameList.count() ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
            {
                if ( buildFilename( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList.at( i ), s_FilenameIn, s_FilenameOut ) == true )
                {
                    err = CliwocConverter( s_FilenameIn, s_FilenameOut, s_FilenameConf, gsl_FilenameList.count() );

                    stopProgress = incFileProgress( gsl_FilenameList.count(), ++i );
                }
                else
                {
                    err = _FILENOTEXISTS_;
                }
            }

            resetFileProgress( gsl_FilenameList.count() );
        }
        else
        {
            err = _CHOOSEABORTED_;
        }
    }
    else
    {
        err = _CHOOSEABORTED_;
    }

// **********************************************************************************************

    endTool( err, stopProgress, gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList, tr( "Done" ), tr( "CLIWOC converter was canceled" ) );

    onError( err );
}
void MainWindow::doGKtoLLConverterFile()
{
    int     i               = 0;
    int     err             = 0;
    int     stopProgress    = 0;

    QString s_FilenameIn    = "";
    QString s_FilenameOut   = "";

// **********************************************************************************************

    if ( existsFirstFile( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList ) == true )
    {
        if ( doGaussKruegerOptionsDialog( _GKLL_, gi_gk_LatitudeColumn, gi_gk_LongitudeColumn, gi_gk_HochColumn, gi_gk_RechtsColumn, gi_gk_StreifenColumn, gi_gk_NumOfDigits_LL, gi_gk_DecimalSeparator, gb_gk_DeleteInputFile ) == QDialog::Accepted )
        {
            initFileProgress( gsl_FilenameList.count(), gsl_FilenameList.at( 0 ), tr( "Converting positions..." ) );

            while ( ( i < gsl_FilenameList.count() ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
            {
                if ( buildFilename( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList.at( i ), s_FilenameIn, s_FilenameOut ) == true )
                {
                    err = GaussKruegerConverter( s_FilenameIn, s_FilenameOut, gi_CodecInput, gi_CodecOutput, gi_Extension, -1, -1, gi_gk_HochColumn, gi_gk_RechtsColumn, gi_gk_StreifenColumn, gi_gk_NumOfDigits_LL, gi_gk_DecimalSeparator, gb_gk_DeleteInputFile, gsl_FilenameList.count() );

                    stopProgress = incFileProgress( gsl_FilenameList.count(), ++i );
                }
                else
                {
                    err = _FILENOTEXISTS_;
                }
            }

            resetFileProgress( gsl_FilenameList.count() );
        }
        else
        {
            err = _CHOOSEABORTED_;
        }
    }
    else
    {
        err = _CHOOSEABORTED_;
    }

// **********************************************************************************************

    endTool( err, stopProgress, gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList, tr( "Done" ), tr( "Converting positions was canceled" ) );

    onError( err );
}
Exemplo n.º 4
0
void MainWindow::doConvertSPE()
{
    int     i               = 0;
    int     err             = 0;
    int     stopProgress    = 0;

    QString s_FilenameIn    = "";
    QString s_FilenameOut   = "";

// **********************************************************************************************

    if ( existsFirstFile( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList ) == true )
    {
        initFileProgress( gsl_FilenameList.count(), gsl_FilenameList.at( 0 ), tr( "Converting SPE data..." ) );

        while ( ( i < gsl_FilenameList.count() ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
        {
            if ( buildFilename( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList.at( i ), s_FilenameIn, s_FilenameOut ) == true )
            {
                err = convertSPE( s_FilenameIn, s_FilenameOut, gi_CodecInput, gi_CodecOutput, gi_EOL, gsl_FilenameList.count() );

                stopProgress = incFileProgress( gsl_FilenameList.count(), ++i );
            }
            else
            {
                err = _FILENOTEXISTS_;
            }
        }

        resetFileProgress( gsl_FilenameList.count() );
    }
    else
    {
        err = _CHOOSEABORTED_;
    }

// **********************************************************************************************

    endTool( err, stopProgress, gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList, tr( "Done" ), tr( "Converting SPE data was canceled" ) );

    onError( err );
}
Exemplo n.º 5
0
void MainWindow::doAddBlock()
{
    int         i                   = 0;
    int         err                 = 0;
    int         stopProgress        = 0;

    QString     s_Text              = "";
    QString     s_dummy             = "";

    QString     s_FilenameIn        = "";
    QString     s_FilenameOut       = "";

    QStringList sl_Text;
    QStringList sl_FilenameListDelete;

    bool        b_dummy             = false;

// **********************************************************************************************

    if ( existsFirstFile( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList ) == true )
    {
        if ( doAddDialog( _ADDBLOCK, gs_ab_Text, s_dummy, gi_ab_LineNo, b_dummy, b_dummy, gb_ab_AddFilename, gb_ab_AddFullPath, gb_ab_AddOrdinalNumber, gb_ab_PrependMetadataColumn, gb_ab_AppendMetadataColumn, gb_ab_SkipEmptyLines, gb_ab_SkipCommentLines, gb_ab_DeleteInputFile ) == QDialog::Accepted )
        {
            initFileProgress( gsl_FilenameList.count(), gsl_FilenameList.at( 0 ), tr( "Adding text block..." ) );

            while ( ( i < gsl_FilenameList.count() ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
            {
                if ( buildFilename( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList.at( i ), s_FilenameIn, s_FilenameOut ) == true )
                {
                    s_Text = gs_ab_Text;
                    s_Text.replace( "^t", "\t" );
                    sl_Text = s_Text.split( "^n" );

                    sl_FilenameListDelete.append( s_FilenameIn );

                    err = addLine( s_FilenameIn, s_FilenameOut, gi_CodecInput, gi_CodecOutput, gi_EOL, sl_Text, gi_ab_LineNo, gb_ab_AddFilename, gb_ab_AddFullPath, gb_ab_AddOrdinalNumber, gb_ab_PrependMetadataColumn, gb_ab_AppendMetadataColumn, gb_ab_SkipEmptyLines, gb_ab_SkipCommentLines, gsl_FilenameList.count() );

                    stopProgress = incFileProgress( gsl_FilenameList.count(), ++i );
                }
                else
                {
                    err = _FILENOTEXISTS_;
                }
            }

            resetFileProgress( gsl_FilenameList.count() );
        }
        else
        {
            err = _CHOOSEABORTED_;
        }
    }
    else
    {
        err = _CHOOSEABORTED_;
    }

// **********************************************************************************************

    if ( ( stopProgress != _APPBREAK_ ) && ( err == _NOERROR_ ) && ( gb_ab_DeleteInputFile == true ) )
    {
        for ( int i=0; i<sl_FilenameListDelete.count(); i++ )
            QFile::remove( sl_FilenameListDelete.at( i ) );
    }

// **********************************************************************************************

    endTool( err, stopProgress, gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList, tr( "Done" ), tr( "Adding text block was canceled" ) );

    onError( err );
}
Exemplo n.º 6
0
void MainWindow::doFindArea()
{
    int             i               = 0;
    int             err             = 0;
    int             stopProgress    = 0;

    QString         s_FilenameIn    = "";
    QString         s_FilenameOut   = "";

    QVector<AreaItem>       v_Area;
    QVector<PositionItem>   v_Position;

// **********************************************************************************************

    if ( existsFirstFile( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList ) == true )
    {
        if ( doFindAreaDialog( gs_AreaDatabaseFilename, gb_fa_DeleteInputFile ) == QDialog::Accepted )
        {
            if ( readAreaDataBaseFile( gs_AreaDatabaseFilename, v_Area, v_Position ) )
            {
                initFileProgress( gsl_FilenameList.count()+1, gsl_FilenameList.at( 0 ), tr( "Finding area ..." ) );

                stopProgress = incFileProgress( gsl_FilenameList.count()+1, 1 );

                while ( ( i < gsl_FilenameList.count() ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
                {

                    if ( buildFilename( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList.at( 0 ), s_FilenameIn, s_FilenameOut ) == true )
                    {
                        err = findArea( s_FilenameIn, s_FilenameOut, gi_CodecInput, gi_CodecOutput, gi_Extension, v_Area, v_Position, gb_fa_DeleteInputFile, gsl_FilenameList.count()+1 );

                        stopProgress = incFileProgress( gsl_FilenameList.count()+1, ++i+1 );
                    }
                    else
                    {
                        err = _FILENOTEXISTS_;
                    }
                }

                resetFileProgress( gsl_FilenameList.count()+1 );
            }
            else
            {
                err = _CHOOSEABORTED_;
            }
        }
        else
        {
            err = _CHOOSEABORTED_;
        }
    }
    else
    {
        err = _CHOOSEABORTED_;
    }

// **********************************************************************************************

    endTool( err, stopProgress, gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList, tr( "Done" ), tr( "Finding area was canceled" ), true, false );

    onError( err );
}
void MainWindow::doReplaceCharactersAtPosition()
{
    int     i               = 0;
    int     err             = 0;
    int     stopProgress    = 0;

    QString s_FilenameIn    = "";
    QString s_FilenameOut   = "";

    QStringList sl_FilenameListDelete;

// **********************************************************************************************

    if ( existsFirstFile( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList ) == true )
    {
        if ( doCharactersAtPositionDialog( _REPLACECHARS, gs_rc_ReplacePositionList, gs_rc_ReplaceStr, gb_ic_SkipEmptyLines, gb_ic_SkipCommentLines, gb_ic_DeleteInputFile ) == QDialog::Accepted )
        {
            initFileProgress( gsl_FilenameList.count(), gsl_FilenameList.at( 0 ), tr( "Replace characters at position..." ) );

            while ( ( i < gsl_FilenameList.count() ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
            {
                if ( buildFilename( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList.at( i ), s_FilenameIn, s_FilenameOut ) == true )
                {
                    sl_FilenameListDelete.append( s_FilenameIn );

                    err = replaceCharactersAtPosition( s_FilenameIn, s_FilenameOut, gi_CodecInput, gi_CodecOutput, gi_EOL, gs_rc_ReplacePositionList, gs_rc_ReplaceStr, gb_ic_SkipEmptyLines, gb_ic_SkipCommentLines, gsl_FilenameList.count() );

                    stopProgress = incFileProgress( gsl_FilenameList.count(), ++i );
                }
                else
                {
                    err = _FILENOTEXISTS_;
                }
            }

            resetFileProgress( gsl_FilenameList.count() );
        }
        else
        {
            err = _CHOOSEABORTED_;
        }
    }
    else
    {
        err = _CHOOSEABORTED_;
    }

// **********************************************************************************************

    if ( ( stopProgress != _APPBREAK_ ) && ( err == _NOERROR_ ) && ( gb_ic_DeleteInputFile == true ) )
    {
        for ( int i=0; i<sl_FilenameListDelete.count(); i++ )
            QFile::remove( sl_FilenameListDelete.at( i ) );
    }

// **********************************************************************************************

    endTool( err, stopProgress, gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList, tr( "Done" ), tr( "Replace characters at position was canceled" ) );

    onError( err );
}
osg::ref_ptr<ossimPlanetImage> ossimPlanetDtedElevationDatabase::getTexture(ossim_uint32 level,
                                                                            ossim_uint64 row,
                                                                            ossim_uint64 col,
                                                                            const ossimPlanetGridUtility& utility)
{
   if(!theOpenFlag)
   {
      return 0;
   }
   
   if(!theEnableFlag)
   {
      return 0;
   }
   double minLat;
   double minLon;
   double maxLat;
   double maxLon;
   ossim_uint32 width = utility.getTileWidth();
   ossim_uint32 height = utility.getTileHeight();

   utility.getLatLonBounds(minLat,
                           minLon,
                           maxLat,
                           maxLon,
                           level,
                           row, 
                           col);

  if(!theExtents->intersectsLatLon(minLat, minLon, maxLat, maxLon))
   {
      return 0;
   }
   double deltaX;
   double deltaY;
   utility.getWidthHeightInDegrees(deltaX, deltaY, level, row, col);
   
   double deltaLat    = deltaY/height;
   ossimDpt gsd = ossimGpt().metersPerDegree();
   gsd.y *= deltaLat;

   osg::ref_ptr<ossimPlanetImage> texture = 0;
   
   if(!theExtents->intersectsScale(gsd.y-FLT_EPSILON,
                                  gsd.y+FLT_EPSILON))//gsd.y <= theExtents.theMaxGsd)
   {
      return 0;
   }
  double minSubRectLat = ossim::max(theExtents->getMinLat(),
                                    minLat);
   double minSubRectLon = ossim::max(theExtents->getMinLon(),
                                    minLon);
   double maxSubRectLat = ossim::min(theExtents->getMaxLat(),
                                   maxLat);
   double maxSubRectLon = ossim::min(theExtents->getMaxLon(),
                                   maxLon);
   ossim_int32 wholeMinLat = (ossim_int32)std::floor(minSubRectLat);
   ossim_int32 wholeMinLon = (ossim_int32)std::floor(minSubRectLon);
   ossim_int32 wholeMaxLat = (ossim_int32)std::floor(maxSubRectLat);
   ossim_int32 wholeMaxLon = (ossim_int32)std::floor(maxSubRectLon);
   

   ossim_int32 lat = wholeMaxLat;
   ossim_int32 lon = wholeMinLon;


//    std::vector<ossimDpt> latLonOrigins;
   std::vector<std::string> latLonOrigins;

   for(;lat >= wholeMinLat; --lat)
   {
      lon = wholeMinLon;
      for(;lon <= wholeMaxLon; ++lon)
      {
         ossimFilename filename = buildFilename(lat, lon);
         if(filename != "")
         {
            latLonOrigins.push_back(filename);
         }
      }
   }

   if(latLonOrigins.size() == 0)
   {
      return 0;
   }
   ossim_uint32 idx  = 0;
   ossim_uint32 numberOfFilesNeeded = latLonOrigins.size();
   texture = new ossimPlanetImage(ossimPlanetTerrainTileId(0,
                                                           level,
                                                           col,
                                                           row));
   ossimRefPtr<ossimImageData> compositeData = new ossimImageData(0,
                                                                  OSSIM_FLOAT32,
                                                                  1,
                                                                  width,
                                                                  height);
   compositeData->setNullPix(OSSIMPLANET_NULL_HEIGHT, 0);
   compositeData->initialize();
   std::vector<ossimPlanetGridUtility::GridPoint> points;
   utility.createGridPoints(points,
                            level,
                            row,
                            col,
                            height,
                            width);

   ossim_uint32 idxPts = 0;
   ossim_uint32 nPoints = points.size();
   osg::Vec3d latLonPoint;
   double minValue = 1.0/DBL_EPSILON -1;
   double maxValue = -1.0/DBL_EPSILON +1;
   //double offset = 0.0;

   for(idx = 0; idx < numberOfFilesNeeded;++idx)
   {

      osg::ref_ptr<ossimPlanetDtedElevationDatabase::DtedInfo> dtedFile = getInfo(latLonOrigins[idx]);

      if(dtedFile.valid())
      {
         ossim_float32* bufPtr = (ossim_float32*)compositeData->getBuf();
         for(idxPts = 0; idxPts < nPoints; ++idxPts)
         {
            utility.getLatLon(latLonPoint, points[idxPts]);
            if((*bufPtr == OSSIMPLANET_NULL_HEIGHT)&&
               (latLonPoint[0] >= dtedFile->theMinLat)&&
               (latLonPoint[0] <= dtedFile->theMaxLat)&&
               (latLonPoint[1] >= dtedFile->theMinLon)&&
               (latLonPoint[1] <= dtedFile->theMaxLon))
            {
               utility.getLatLon(latLonPoint, points[idxPts]);
               ossim_float64 nullHeight = dtedFile->theHandler->getNullHeightValue();
              double h = dtedFile->theHandler->getHeightAboveMSL(ossimGpt(latLonPoint[0],
                                                                           latLonPoint[1]));
               if(!ossim::isnan(h)&&
                  (h!=nullHeight))
               {
                  if(theGeoRefModel.valid())
                  {
                     h+=theGeoRefModel->getGeoidOffset(latLonPoint[0], latLonPoint[1]);
                  }
                  *bufPtr = h;
                  if(*bufPtr < minValue)
                  {
                     minValue = *bufPtr;
                  }
                  if(*bufPtr > maxValue)
                  {
                     maxValue = *bufPtr;
                  }
               }   
               else
               {
                  *bufPtr = 0;
               }
            }
            ++bufPtr;
         }
      }
   }
   compositeData->validate();

   if(compositeData->getDataObjectStatus() != OSSIM_EMPTY)
   {
      texture->fromOssimImage(compositeData, false);
      if(minValue < maxValue)
      {
         texture->setMinMax(minValue, maxValue);
      }
   }
   else
   {
      texture = 0;
   }

   return texture;

}
bool ossimPlanetDtedElevationDatabase::hasTexture(ossim_uint32 width,
                                                  ossim_uint32 height,
                                                  const ossimPlanetTerrainTileId& tileId,
                                                  const ossimPlanetGrid& grid)
{
   if(!theOpenFlag)
   {
      return false;
   }
   
   if(!theEnableFlag)
   {
      return false;
   }
   ossimPlanetGrid::GridBound bound;
   if(grid.findGridBound(tileId.face(),
                         ossimPlanetGrid::ModelPoint(theExtents->getMinLon(), theExtents->getMinLat()),
                         ossimPlanetGrid::ModelPoint(theExtents->getMaxLon(), theExtents->getMaxLat()),
                         bound))
   {
      ossimPlanetGrid::GridBound tileBound;
      grid.bounds(tileId,tileBound);
      if(!tileBound.toDrect().intersects(bound.toDrect()))
      {
         return false;
      }
   }
   osg::Vec2d deltaXY;
   grid.widthHeightInModelSpace(tileId, deltaXY);
   double deltaLat    = (deltaXY[1])/(double)(height);
   
   ossimDpt gsd = ossimGpt().metersPerDegree();
   gsd.y *= deltaLat;
   ossimPlanetGrid::ModelPoint minLatLon, maxLatLon;
   grid.modelBound(tileId, minLatLon, maxLatLon);
   if((gsd.y >= theExtents->getMinScale()) &&
      (gsd.y <= theExtents->getMaxScale()))
   {
      ossimPlanetGrid::ModelPoints points;
      grid.createModelPoints(tileId,
                             width,
                             height,
                             points);
      ossim_float64 minModelX, minModelY, maxModelX, maxModelY;
      ossim_uint32 idxPts = 0;
      ossim_uint32 nPoints = points.size();
      minModelX = points[0].x();
      maxModelX = minModelX;
      minModelY = points[0].y();
      maxModelY = minModelY;
      ossimPlanetGrid::ModelPoint* optimizedOutPtr = &points.front();
      ++optimizedOutPtr;
      for(idxPts = 1; idxPts < nPoints; ++idxPts,++optimizedOutPtr)
      {
         if(optimizedOutPtr->x() < minModelX) minModelX = optimizedOutPtr->x();
         if(optimizedOutPtr->x() > maxModelX) maxModelX = optimizedOutPtr->x();
         if(optimizedOutPtr->y() < minModelY) minModelY = optimizedOutPtr->y();
         if(optimizedOutPtr->y() > maxModelY) maxModelY = optimizedOutPtr->y();
      }
      ossim_int32 wholeMinY = (ossim_int32)std::floor(minModelY);
      ossim_int32 wholeMinX = (ossim_int32)std::floor(minModelX);
      ossim_int32 wholeMaxY = (ossim_int32)std::floor(maxModelY);
      ossim_int32 wholeMaxX = (ossim_int32)std::floor(maxModelX);
      
      
      ossim_int32 lat = wholeMaxY;
      ossim_int32 lon = wholeMinX;
      
      
      //    std::vector<ossimDpt> latLonOrigins;
      std::vector<std::string> latLonOrigins;
      
      for(;lat >= wholeMinY; --lat)
      {
         lon = wholeMinX;
         for(;lon <= wholeMaxX; ++lon)
         {
            ossimFilename filename = buildFilename(lat, lon);
            if(filename != "")
            {
               return true;
            }
         }
      }
   }
   
   return false;
}
osg::ref_ptr<ossimPlanetImage> ossimPlanetSrtmElevationDatabase::getTexture(ossim_uint32 width,
                                                                            ossim_uint32 height,
                                                                            const ossimPlanetTerrainTileId& tileId,
                                                                            const ossimPlanetGrid& grid,
                                                                            ossim_int32 padding)
{
   if(!theEnableFlag)
   {
      return 0;
   }
   osg::ref_ptr<ossimPlanetImage> texture;
   ossimPlanetGrid::GridBound bound;
   ossimPlanetGrid::GridBound tileBound;
   if(grid.findGridBound(tileId.face(),
                         ossimPlanetGrid::ModelPoint(theExtents->getMinLon(), theExtents->getMinLat()),
                         ossimPlanetGrid::ModelPoint(theExtents->getMaxLon(), theExtents->getMaxLat()),
                         bound))
   {
      grid.bounds(tileId,tileBound);
      if(!tileBound.toDrect().intersects(bound.toDrect()))
      {
         return 0;
      }
   }
   
   osg::Vec2d deltaXY;
   grid.widthHeightInModelSpace(tileId, deltaXY);
   double deltaLat    = (deltaXY[1])/(double)(height);
   ossimDpt gsd = ossimGpt().metersPerDegree();
   gsd.y *= deltaLat;
   if(gsd.y < theExtents->getMaxScale())
   {
      ossimPlanetGrid::ModelPoints points;
      grid.createModelPoints(tileId,
                             width,
                             height,
                             points,
                             padding);
      ossim_uint32 idxPts = 0;
      ossim_uint32 nPoints = points.size();
      ossimPlanetGrid::ModelPoint* optimizedOutPtr = &points.front();
      texture = new ossimPlanetImage(tileId);
      ossimRefPtr<ossimImageData> compositeData = new ossimImageData(0,
                                                                     OSSIM_FLOAT32,
                                                                     1,
                                                                     width+2*padding,
                                                                     height+2*padding);
      compositeData->setNullPix(OSSIMPLANET_NULL_HEIGHT, 0);
      compositeData->initialize();
      texture->setPadding(padding);
      ossim_float32* bufPtr = (ossim_float32*)compositeData->getBuf();
      ossimElevManager* manager = ossimElevManager::instance();
      double minValue = 999999999.0;
      double maxValue = -999999999.0;
      for(idxPts = 0; idxPts < nPoints; ++idxPts,++optimizedOutPtr)
      {
         double h = manager->getHeightAboveEllipsoid(ossimGpt((*optimizedOutPtr).y(), (*optimizedOutPtr).x()));
         if(!ossim::isnan(h))
         {
            *bufPtr = h;
         }
         
         ++bufPtr;
      }
      compositeData->validate();
      if(compositeData->getDataObjectStatus() != OSSIM_EMPTY)
      {
         texture->fromOssimImage(compositeData, false);
         if(minValue < maxValue)
         {
            texture->setMinMax(minValue, maxValue);
         }
      }
      else
      {
         texture = 0;
      }
   }
#if 0
   if(!theOpenFlag)
   {
      return 0;
   }
   
   if(!theEnableFlag)
   {
      return 0;
   }
   osg::ref_ptr<ossimPlanetImage> texture;
   ossimPlanetGrid::GridBound bound;
   ossimPlanetGrid::GridBound tileBound;
   if(grid.findGridBound(tileId.face(),
                         ossimPlanetGrid::ModelPoint(theExtents->getMinLon(), theExtents->getMinLat()),
                         ossimPlanetGrid::ModelPoint(theExtents->getMaxLon(), theExtents->getMaxLat()),
                         bound))
   {
      grid.bounds(tileId,tileBound);
      if(!tileBound.toDrect().intersects(bound.toDrect()))
      {
         return 0;
      }
   }
   
   osg::Vec2d deltaXY;
   grid.widthHeightInModelSpace(tileId, deltaXY);
   double deltaLat    = (deltaXY[1])/(double)(height);
   double deltaLon    = (deltaXY[0])/(double)(width);
   ossimDpt gsd = ossimGpt().metersPerDegree();
   gsd.y *= deltaLat;
   if(gsd.y < theExtents->getMaxScale())
   {
      ossimPlanetGrid::ModelPoints points;
      grid.createModelPoints(tileId,
                             width,
                             height,
                             points,
                             padding);
      ossim_float64 minModelX, minModelY, maxModelX, maxModelY;
      ossim_uint32 idxPts = 0;
      ossim_uint32 nPoints = points.size();
      minModelX = points[0].x();
      maxModelX = minModelX;
      minModelY = points[0].y();
      maxModelY = minModelY;
      ossimPlanetGrid::ModelPoint* optimizedOutPtr = &points.front();
      ++optimizedOutPtr;
      for(idxPts = 1; idxPts < nPoints; ++idxPts,++optimizedOutPtr)
      {
         if(optimizedOutPtr->x() < minModelX) minModelX = optimizedOutPtr->x();
         if(optimizedOutPtr->x() > maxModelX) maxModelX = optimizedOutPtr->x();
         if(optimizedOutPtr->y() < minModelY) minModelY = optimizedOutPtr->y();
         if(optimizedOutPtr->y() > maxModelY) maxModelY = optimizedOutPtr->y();
      }
      ossim_int32 wholeMinY = (ossim_int32)std::floor(minModelY);
      ossim_int32 wholeMinX = (ossim_int32)std::floor(minModelX);
      ossim_int32 wholeMaxY = (ossim_int32)std::floor(maxModelY);
      ossim_int32 wholeMaxX = (ossim_int32)std::floor(maxModelX);
      
      
      ossim_int32 lat = wholeMaxY;
      ossim_int32 lon = wholeMinX;
      
      
      //    std::vector<ossimDpt> latLonOrigins;
      std::vector<std::string> latLonOrigins;
      
      for(;lat >= wholeMinY; --lat)
      {
         lon = wholeMinX;
         for(;lon <= wholeMaxX; ++lon)
         {
            ossimFilename filename = buildFilename(lat, lon);
            if(filename != "")
            {
               latLonOrigins.push_back(filename);
            }
         }
      }
      
      osg::Vec3d latLonPoint;
      double minValue = 1.0/DBL_EPSILON -1;
      double maxValue = -1.0/DBL_EPSILON +1;
      if(latLonOrigins.size() == 0)
      {
         return 0;
      }
      ossim_uint32 idx  = 0;
      ossim_uint32 numberOfFilesNeeded = latLonOrigins.size();
      texture = new ossimPlanetImage(tileId);
      ossimRefPtr<ossimImageData> compositeData = new ossimImageData(0,
                                                                     OSSIM_FLOAT32,
                                                                     1,
                                                                     width+2*padding,
                                                                     height+2*padding);
      compositeData->setNullPix(OSSIMPLANET_NULL_HEIGHT, 0);
      compositeData->initialize();
      texture->setPadding(padding);
      for(idx = 0; idx < numberOfFilesNeeded;++idx)
      {
         osg::ref_ptr<ossimPlanetSrtmElevationDatabase::SrtmInfo> srtmFile = getInfo(latLonOrigins[idx]);
         
         if(srtmFile.valid())
         {
            ossim_float64 nullHeight = srtmFile->theSrtmHandler->getNullHeightValue();
            ossim_float32* bufPtr = (ossim_float32*)compositeData->getBuf();
            optimizedOutPtr = &points.front();      
            for(idxPts = 0; idxPts < nPoints; ++idxPts,++optimizedOutPtr)
            {
               if((*bufPtr == OSSIMPLANET_NULL_HEIGHT)&&
                  (optimizedOutPtr->y() >= srtmFile->theMinLat)&&
                  (optimizedOutPtr->y() <= srtmFile->theMaxLat)&&
                  (optimizedOutPtr->x() >= srtmFile->theMinLon)&&
                  (optimizedOutPtr->x() <= srtmFile->theMaxLon))
               {
                  double h = srtmFile->theSrtmHandler->getHeightAboveMSL(ossimGpt(optimizedOutPtr->y(),
                                                                              optimizedOutPtr->x()));
                  if(!ossim::isnan(h)&&
                     (h!=nullHeight))
                  {
                     if(theGeoRefModel.valid())
                     {
                        h+=theGeoRefModel->getGeoidOffset(optimizedOutPtr->y(), optimizedOutPtr->x());
                     }
                     *bufPtr = h;
                     if(h < minValue)
                     {
                        minValue = h;
                     }
                     if(h > maxValue)
                     {
                        maxValue = h;
                     }
                  }   
                  else
                  {
                     *bufPtr = 0;
                  }
               }
               ++bufPtr;
            }
         }
      }
      compositeData->validate();
      if(compositeData->getDataObjectStatus() != OSSIM_EMPTY)
      {
         texture->fromOssimImage(compositeData, false);
         if(minValue < maxValue)
         {
            texture->setMinMax(minValue, maxValue);
         }
      }
      else
      {
         texture = 0;
      }
   }
#endif
   return texture;
   
}
Exemplo n.º 11
0
void MainWindow::doTransposeTable()
{
    int     i               = 0;
    int     err             = 0;
    int     stopProgress    = 0;

    QString s_FilenameIn    = "";
    QString s_FilenameOut   = "";

    QStringList sl_FilenameListDelete;

// **********************************************************************************************

    if ( existsFirstFile( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList ) == true )
    {
        if ( doTransposeTableOptionsDialog( gi_tt_CodecInput, gi_tt_CodecOutput, gi_tt_EOL, gb_tt_DeleteInputFile ) == QDialog::Accepted )
        {
            initFileProgress( gsl_FilenameList.count(), gsl_FilenameList.at( 0 ), tr( "Transposing tables..." ) );

            while ( ( i < gsl_FilenameList.count() ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
            {
                if ( buildFilename( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList.at( i ), s_FilenameIn, s_FilenameOut ) == true )
                {
                    sl_FilenameListDelete.append( s_FilenameIn );

                    err = transposeTable( s_FilenameIn, s_FilenameOut, gi_tt_CodecInput, gi_tt_CodecOutput, gi_tt_EOL, gsl_FilenameList.count() );

                    stopProgress = incFileProgress( gsl_FilenameList.count(), ++i );
                }
                else
                {
                    err = _FILENOTEXISTS_;
                }
            }

            resetFileProgress( gsl_FilenameList.count() );
        }
        else
        {
            err = _CHOOSEABORTED_;
        }

    }
    else
    {
        err = _CHOOSEABORTED_;
    }

// **********************************************************************************************

    if ( ( stopProgress != _APPBREAK_ ) && ( err == _NOERROR_ ) && ( gb_tt_DeleteInputFile == true ) )
    {
        for ( int i=0; i<sl_FilenameListDelete.count(); i++ )
            QFile::remove( sl_FilenameListDelete.at( i ) );
    }

// **********************************************************************************************

    endTool( err, stopProgress, gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList, tr( "Done" ), tr( "Transposing tables was canceled" ) );

    onError( err );
}