コード例 #1
0
rspfRefPtr<rspfImageData> rspfCacheTileSource::getTile(
   const rspfIrect& tileRect, rspf_uint32 resLevel)
{
   rspfRefPtr<rspfImageData> result = 0;
   
   if ( theInputConnection )
   {
      if ( isSourceEnabled() )
      {
         if(!theTile.valid())
         {
            allocate();
         }
         
         if (theTile.valid())
         {
            theTile->setImageRectangle(tileRect);
            theTile->makeBlank();
            // see if we can get a valid cache at the given resolution level
            if(getCacheId(resLevel) < 0)
            {
               return theInputConnection->getTile(tileRect, resLevel);
            }
            result = fillTile(resLevel);
         }
      }
      else // Not enabled...
      {
         result = theInputConnection->getTile(tileRect, resLevel);
      }

   } // End:  if ( theInputConnection )

   return result;
}
コード例 #2
0
ファイル: map.cpp プロジェクト: tumic0/GPXSee
void Map::loadTilesSync(QList<Tile> &list)
{
	QList<Download> dl;

	for (int i = 0; i < list.size(); i++) {
		Tile &t = list[i];
		QString file = tileFile(t);
		QFileInfo fi(file);

		if (!fi.exists())
			dl.append(Download(tileUrl(t), file));
		else
			loadTileFile(t, file);
	}

	if (dl.empty())
		return;

	QEventLoop wait;
	connect(&Downloader::instance(), SIGNAL(finished()), &wait, SLOT(quit()));
	if (Downloader::instance().get(dl))
		wait.exec();

	for (int i = 0; i < list.size(); i++) {
		Tile &t = list[i];

		if (t.pixmap().isNull()) {
			QString file = tileFile(t);
			QFileInfo fi(file);

			if (!(fi.exists() && loadTileFile(t, file)))
				fillTile(t);
		}
	}
}
コード例 #3
0
double SRTMProvider::getAltitude(double lat, double lon)
{
    double altitude = 0.0; // Defaultwert für Höhe ist NN
    
    index = latLonToIndex(int(floor(lat)), int(floor(lon)));
    
    SRTMTile *tile = new SRTMTile(index);
    lock.lockForRead();
    if(tileCache.contains(index)){
        tile = tileCache[index];
    }
    else 
    {
        lock.unlock();
        lock.lockForWrite();
        if(fillTile(index, &tile)){
            tileCache.insert(index, tile);
        }
        else{
            lock.unlock();
            return altitude;
        }
    }
    //lock.unlock();
    
    //lock.lockForRead();
    altitude = tile->getAltitudeFromLatLon(lat, lon);
    lock.unlock();
    
    return altitude;
}
コード例 #4
0
ファイル: oubliette.cpp プロジェクト: FilipBE/qtextended
void Oubliette::paintOubliette(QPainter *p, const QRect &paintRect)
{
   // snap down
    int tile_x1 = paintRect.x() / TileWidth;
    int tile_y1 = paintRect.y() / TileHeight;

    // snap up
    int tile_x2 = (paintRect.x() + paintRect.width()) / TileWidth + TileWidth;
    int tile_y2 = (paintRect.y() + paintRect.height()) / TileHeight + TileHeight;

    OublietteLevel *level = m_oubliettePlan.level(m_currentLevel);
    for (int y = tile_y1; y <= tile_y2; ++y) {
        for (int x = tile_x1; x <= tile_x2; ++x) {
            fillTile(p, x, y, level->tile(x, y));
        }
    }
}
コード例 #5
0
ファイル: map.cpp プロジェクト: tumic0/GPXSee
void Map::loadTilesAsync(QList<Tile> &list)
{
	QList<Download> dl;

	for (int i = 0; i < list.size(); i++) {
		Tile &t = list[i];
		QString file = tileFile(t);
		QFileInfo fi(file);

		if (!fi.exists()) {
			fillTile(t);
			dl.append(Download(tileUrl(t), file));
		} else
			loadTileFile(t, file);
	}

	if (!dl.empty())
		Downloader::instance().get(dl);
}
コード例 #6
0
ファイル: samplegen.cpp プロジェクト: UIKit0/aqsis
void makeTileSet(std::vector<int>& tiles, int width, std::vector<float>& tuv,
                 float timeStratQuality)
{
    assert(timeStratQuality >= 0 && timeStratQuality <= 1);
    assert(width >= 4);
    assert((int)tuv.size() == 3*width*width);
    // Radius of region over which to evenly distribute samples
    int r = 2;
    if(width < 8)
        r = 1;
    // Number of tile colors
    const int ncol = 3;

    // Edge tile width
    int eWidth = r + r%2;
    // Corner tile width
    int cWidth = 2*r + eWidth;

    int fullwidth = width + eWidth;
    // Working space for computing tiles.
    std::vector<int> tileStor(fullwidth*fullwidth, -1);
    int* tile = cbegin(tileStor);

    // First, create corner tiles
    // --------------------------
    int cSize = cWidth*cWidth;
    std::vector<int> cornerStor(cSize*3,-1);
    int* corners[] = { cbegin(cornerStor),
                       cbegin(cornerStor) + cSize,
                       cbegin(cornerStor) + 2*cSize };
    fillTile(tile, width, width, r, cbegin(tuv), timeStratQuality);
    copyBlock2d(corners[0], cWidth, tile, width, 0,0, 0,0, cWidth,cWidth);
    if(2*cWidth <= width)
    {
        // cWidth is small enough that we can cut out two more corner tiles
        // from the original tile
        copyBlock2d(corners[1], cWidth, tile, width, 0,0, width/2,0, cWidth,cWidth);
        copyBlock2d(corners[2], cWidth, tile, width, 0,0, width/2,width/2, cWidth,cWidth);
    }
    else
    {
        // else need to optimize a new tile to cut out each corner, to avoid
        // duplication of sample patterns
        tileStor.assign(tileStor.size(), -1);
        fillTile(tile, width, width, r, cbegin(tuv), timeStratQuality);
        copyBlock2d(corners[1], cWidth, tile, width, 0,0, 0,0, cWidth,cWidth);
        tileStor.assign(tileStor.size(), -1);
        fillTile(tile, width, width, r, cbegin(tuv), timeStratQuality);
        copyBlock2d(corners[2], cWidth, tile, width, 0,0, 0,0, cWidth,cWidth);
    }
    // Overwrite sections of the corner tiles with -1 (the invalid index) This
    // makes sure the corner tiles take up the minimum number of tuv indices
    // possible.
    for(int j = 0; j < cWidth; ++j)
    {
        for(int i = 0; i < cWidth; ++i)
        {
            if((i < r || i >= cWidth-r) && (j < r || j >= cWidth-r))
            {
                corners[0][j*cWidth + i] = -1;
                corners[1][j*cWidth + i] = -1;
                corners[2][j*cWidth + i] = -1;
            }
        }
    }

    // Second, create edge tiles
    // -------------------------
    int eLen = width - cWidth;
    int eSize = eLen*eWidth;
    int nEdges = ncol*ncol; // number of horizontal or vertical edges
    std::vector<int> edgeStor(eSize*2*nEdges,-1);
    std::vector<int*> horizEdges(nEdges);
    std::vector<int*> vertEdges(nEdges);
    for(int iedge = 0; iedge < nEdges; ++iedge)
    {
        horizEdges[iedge] = &edgeStor[eSize*iedge];
        vertEdges[iedge] = &edgeStor[eSize*(iedge+nEdges)];
        // Corner indices for current edges
        int c1 = iedge % ncol;
        int c2 = iedge / ncol;
        // Insert corner samples into top left and top right of tile:
        //
        // +--------------+
        // |C            C|  C = corner
        // |CCeeeeeeeeeeCC|  e = edge to be extracted
        // |CCeeeeeeeeeeCC|
        // |C            C|
        // |              |
        // .              .
        int cw2 = cWidth/2;
        tileStor.assign(tileStor.size(), -1);
        copyBlock2d(tile, width, corners[c1], cWidth,
                    0,0, cw2,0, cw2,cWidth);
        copyBlock2d(tile, width, corners[c2], cWidth,
                    width-cw2,0, 0,0, cw2,cWidth);
        // optimize tile & extract newly optimized edge
        fillTile(tile, width, width, r, cbegin(tuv), timeStratQuality);
        copyBlock2d(horizEdges[iedge], eLen, tile, width,
                    0,0, cw2,r, eLen,eWidth);

        // Now do the same thing for the vertical edges.
        tileStor.assign(tileStor.size(), -1);
        copyBlock2d(tile, width, corners[c1], cWidth,
                    0,0, 0,cw2, cWidth,cw2);
        copyBlock2d(tile, width, corners[c2], cWidth,
                    0,width-cw2, 0,0, cWidth,cw2);
        fillTile(tile, width, width, r, cbegin(tuv), timeStratQuality);
        copyBlock2d(vertEdges[iedge], eWidth, tile, width,
                    0,0, r,cw2, eWidth,eLen);
    }

    // Third, create the full tiles
    // ----------------------------
    // We now have a consistent set of coloured corners and all possible
    // associated edges.  Fill in the tiles themselves using these corners &
    // edges as the boundaries

    // Record tile positions which need to have the indices de-duplicated.
    std::vector<int> deDupInd;
    deDupInd.reserve(2*width*eWidth - eWidth*eWidth);
    int ew2 = eWidth/2;
    for(int j = 0; j < width; ++j)
        for(int i = 0; i < width; ++i)
        {
            if((i < ew2 || i >= width-ew2) || (j < ew2 || j >= width-ew2))
                deDupInd.push_back((j+ew2)*fullwidth + i+ew2);
        }

    int nsamps = width*width;
    int ntiles = ncol*ncol*ncol*ncol;
    tiles.assign(nsamps*ntiles,-1);
    for(int itile = 0; itile < ntiles; ++itile)
    {
        // Fill in tile boundaries to look something like
        //
        // c1              c2
        //    CCCeeeeeeCCC
        //    CCCeeeeeeCCC
        //    CC--------CC
        //    ee--------ee
        //    ee--------ee
        //    CC--------CC
        //    CCCeeeeeeCCC
        //    CCCeeeeeeCCC
        // c3              c4
        //
        // corner indices
        int c1 = itile % ncol;
        int c2 = (itile/ncol) % ncol;
        int c3 = (itile/(ncol*ncol)) % ncol;
        int c4 = itile/(ncol*ncol*ncol);
        // Fill in corners
        tileStor.assign(tileStor.size(), -1);
        int cw = cWidth-r;
        copyBlock2d(tile, fullwidth, corners[c1], cWidth,
                    0,0, r,r, cw,cw);
        copyBlock2d(tile, fullwidth, corners[c2], cWidth,
                    fullwidth-cw,0, 0,r, cw,cw);
        copyBlock2d(tile, fullwidth, corners[c2], cWidth,
                    0,fullwidth-cw, r,0, cw,cw);
        copyBlock2d(tile, fullwidth, corners[c2], cWidth,
                    fullwidth-cw,fullwidth-cw, 0,0, cw,cw);
        // Fill in edges
        copyBlock2d(tile, fullwidth, horizEdges[ncol*c2 + c1], eLen,
                    cw,0, 0,0, eLen,eWidth);
        copyBlock2d(tile, fullwidth, horizEdges[ncol*c4 + c3], eLen,
                    cw,fullwidth-eWidth, 0,0, eLen,eWidth);
        copyBlock2d(tile, fullwidth, vertEdges[ncol*c3 + c1], eWidth,
                    0,cw, 0,0, eWidth,eLen);
        copyBlock2d(tile, fullwidth, vertEdges[ncol*c4 + c2], eWidth,
                    fullwidth-eWidth,cw, 0,0, eWidth,eLen);

        // Remove duplicate indices inside the central width x width region
        std::sort(deDupInd.begin(), deDupInd.end(), IndirectLessFunctor(tile));
        for(int k = 0, kend=deDupInd.size()-1; k < kend; ++k)
        {
            int currSamp = tile[deDupInd[k]];
            if(tile[deDupInd[k+1]] == currSamp)
            {
                // currSamp is a duplicate of the next sample index, choose
                // the next closest sample instead, as measured by the
                // distance in time-lens space.
                float t = tuv[3*currSamp];
                float u = tuv[3*currSamp+1];
                float v = tuv[3*currSamp+2];
                float tWeight = 4*timeStratQuality;
                float uvWeight = 1 - timeStratQuality;
                float minDist2 = FLT_MAX;
                int bestReplacement = -1;
                for(int isamp = 0; isamp < nsamps; ++isamp)
                {
                    if(isamp == currSamp)
                        continue;
                    float dt = t - tuv[3*isamp];
                    float du = u - tuv[3*isamp+1];
                    float dv = v - tuv[3*isamp+2];
                    float dist2 = tWeight*dt*dt + uvWeight*(du*du + dv*dv);
                    if(dist2 < minDist2)
                    {
                        // isamp looks promising out of the ones we've tried
                        // so far, but check that it's not already used before
                        // storing it.
                        bool valid = true;
                        // simple linear search.  This shouldn't be called very
                        // many times.
                        for(int i = 0, iend = deDupInd.size(); i < iend; ++i)
                        {
                            if(tile[deDupInd[i]] == isamp)
                            {
                                valid = false;
                                break;
                            }
                        }
                        if(valid)
                        {
                            bestReplacement = isamp;
                            minDist2 = dist2;
                        }
                    }
                }
                assert(bestReplacement != -1);
                tile[deDupInd[k]] = bestReplacement;
            }
        }

        // Optimize tile & save the result
        fillTile(tile, fullwidth, width, r, cbegin(tuv), timeStratQuality);
        copyBlock2d(&tiles[nsamps*itile], width, tile, fullwidth,
                    0,0, eWidth/2,eWidth/2, width,width);
    }
}
コード例 #7
0
ファイル: ossimShiftFilter.cpp プロジェクト: ossimlabs/ossim
ossimRefPtr<ossimImageData> ossimShiftFilter::getTile(
   const ossimIrect& tileRect,
   ossim_uint32 resLevel)
{
   ossimRefPtr<ossimImageData> result = 0;
   
   if ( theInputConnection )
   {
      ossimRefPtr<ossimImageData> inputTile = theInputConnection->getTile( tileRect, resLevel );
      
      if ( inputTile.get() && isSourceEnabled() &&
           !ossim::isnan(m_null) && !ossim::isnan(m_min) && !ossim::isnan(m_max) )
      {
         // Get its status of the input tile.
         ossimDataObjectStatus tile_status = inputTile->getDataObjectStatus();
         
         if ( tile_status != OSSIM_NULL )
         {
            if ( !m_tile )
            {
               allocate(); // First time through.
            }
            
            if ( tile_status != OSSIM_EMPTY )
            {
               // Set the origin,bands of the output tile.
               m_tile->setImageRectangle(tileRect);

               switch(inputTile->getScalarType())
               {
                  case OSSIM_UINT8:
                  {
                     fillTile( ossim_uint8(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_SINT8:
                  {
                     fillTile( ossim_sint8(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_UINT16:
                  case OSSIM_USHORT11:
                  {
                     fillTile( ossim_uint16(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_SINT16:
                  {
                     fillTile( ossim_sint16(0), inputTile.get(), m_tile.get() ); 
                     break;
                  }
                  case OSSIM_SINT32:
                  {
                     fillTile( ossim_sint32(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_UINT32:
                  {
                     fillTile( ossim_uint32(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_FLOAT32: 
                  case OSSIM_NORMALIZED_FLOAT:
                  {
                     fillTile( ossim_float32(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_FLOAT64:
                  case OSSIM_NORMALIZED_DOUBLE:
                  {
                     fillTile( ossim_float64(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_SCALAR_UNKNOWN:
                  default:
                  {
                     ossimNotify(ossimNotifyLevel_WARN)
                        << "ossimShiftFilter::getTile ERROR Unhandled scalar!" << endl;
                        break;
                  }
            
               } // Matches: switch(inputTile->getScalarType())

               m_tile->validate();
            }
            else
            {
               m_tile->makeBlank();
            }

            result = m_tile;
            
         } // Matches: if ( tile_status != OSSIM_NULL )
            
      } // Matches: if ( inputTile.get() ... )

      if ( !result && inputTile.get() )
      {
         result = inputTile;
      }
           
   } // Matches: if ( theInputConnection ) 
   
   return result;
}
コード例 #8
0
ファイル: ossimPngReader.cpp プロジェクト: Dukeke/ossim
bool ossimPngReader::getTile(ossimImageData* result,
                             ossim_uint32 resLevel)
{
   bool status = false;
   
   //---
   // Not open, this tile source bypassed, or invalid res level,
   // return a blank tile.
   //---
   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      result->ref(); // Increment ref count.
      
      //---
      // Check for overview tile.  Some overviews can contain r0 so always
      // call even if resLevel is 0.  Method returns true on success, false
      // on error.
      //---
      status = getOverviewTile(resLevel, result);

      if (status)
      {
         if(m_outputScalarType == OSSIM_UINT16)
         {
            //---
            // Temp fix:
            // The overview handler could return a tile of OSSIM_USHORT11 if
            // the max sample value was not set to 2047.
            //
            // To prevent a scalar mismatch set 
            //---
            result->setScalarType(m_outputScalarType);
         }
      }
      
      if (!status) // Did not get an overview tile.
      {
         status = true;
         
         ossimIrect tile_rect = result->getImageRectangle();

         if ( ! tile_rect.completely_within(getImageRectangle(0)) )
         {
            // We won't fill totally so make blank first.
            m_tile->makeBlank();
         }
         
         if (getImageRectangle(0).intersects(tile_rect))
         {
            // Make a clip rect.
            ossimIrect clip_rect = tile_rect.clipToRect(getImageRectangle(0));
            
            // This will validate the tile at the end.
            fillTile(clip_rect, result);
         }
      }

      result->unref();  // Decrement ref count.
   }

   return status;
}