当前位置: 首页>>代码示例>>C++>>正文


C++ GeoExtent::crossesAntimeridian方法代码示例

本文整理汇总了C++中GeoExtent::crossesAntimeridian方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoExtent::crossesAntimeridian方法的具体用法?C++ GeoExtent::crossesAntimeridian怎么用?C++ GeoExtent::crossesAntimeridian使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeoExtent的用法示例。


在下文中一共展示了GeoExtent::crossesAntimeridian方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: clampAndTransformExtent

void
Profile::getIntersectingTiles(const GeoExtent& extent, unsigned localLOD, std::vector<TileKey>& out_intersectingKeys) const
{
    GeoExtent ext = extent;

    // reproject into the profile's SRS if necessary:
    if ( !getSRS()->isHorizEquivalentTo( extent.getSRS() ) )
    {
        // localize the extents and clamp them to legal values
        ext = clampAndTransformExtent( extent );
        if ( !ext.isValid() )
            return;
    }

    if ( ext.crossesAntimeridian() )
    {
        GeoExtent first, second;
        if (ext.splitAcrossAntimeridian( first, second ))
        {
            addIntersectingTiles( first, localLOD, out_intersectingKeys );
            addIntersectingTiles( second, localLOD, out_intersectingKeys );
        }
    }
    else
    {
        addIntersectingTiles( ext, localLOD, out_intersectingKeys );
    }
}
开发者ID:ldelgass,项目名称:osgearth,代码行数:28,代码来源:Profile.cpp

示例2: getTileDimensions

void
Profile::addIntersectingTiles(const GeoExtent& key_ext, unsigned localLOD, std::vector<TileKey>& out_intersectingKeys) const
{
    // assume a non-crossing extent here.
    if ( key_ext.crossesAntimeridian() )
    {
        OE_WARN << "Profile::addIntersectingTiles cannot process date-line cross" << std::endl;
        return;
    }

    int tileMinX, tileMaxX;
    int tileMinY, tileMaxY;

    double destTileWidth, destTileHeight;
    getTileDimensions(localLOD, destTileWidth, destTileHeight);

    //OE_DEBUG << std::fixed << "  Source Tile: " << key.getLevelOfDetail() << " (" << keyWidth << ", " << keyHeight << ")" << std::endl;
    //OE_DEBUG << std::fixed << "  Dest Size: " << destLOD << " (" << destTileWidth << ", " << destTileHeight << ")" << std::endl;

    double east = key_ext.xMax() - _extent.xMin();
    bool xMaxOnTileBoundary = fmod(east, destTileWidth) == 0.0;

    double south = _extent.yMax() - key_ext.yMin();
    bool yMaxOnTileBoundary = fmod(south, destTileHeight) == 0.0;

    tileMinX = (int)((key_ext.xMin() - _extent.xMin()) / destTileWidth);
    tileMaxX = (int)(east / destTileWidth) - (xMaxOnTileBoundary ? 1 : 0);

    tileMinY = (int)((_extent.yMax() - key_ext.yMax()) / destTileHeight); 
    tileMaxY = (int)(south / destTileHeight) - (yMaxOnTileBoundary ? 1 : 0);

    unsigned int numWide, numHigh;
    getNumTiles(localLOD, numWide, numHigh);

    // bail out if the tiles are out of bounds.
    if ( tileMinX >= (int)numWide || tileMinY >= (int)numHigh ||
         tileMaxX < 0 || tileMaxY < 0 )
    {
        return;
    }

    tileMinX = osg::clampBetween(tileMinX, 0, (int)numWide-1);
    tileMaxX = osg::clampBetween(tileMaxX, 0, (int)numWide-1);
    tileMinY = osg::clampBetween(tileMinY, 0, (int)numHigh-1);
    tileMaxY = osg::clampBetween(tileMaxY, 0, (int)numHigh-1);

    OE_DEBUG << std::fixed << "  Dest Tiles: " << tileMinX << "," << tileMinY << " => " << tileMaxX << "," << tileMaxY << std::endl;

    for (int i = tileMinX; i <= tileMaxX; ++i)
    {
        for (int j = tileMinY; j <= tileMaxY; ++j)
        {
            //TODO: does not support multi-face destination keys.
            out_intersectingKeys.push_back( TileKey(localLOD, i, j, this) );
        }
    }
}
开发者ID:ldelgass,项目名称:osgearth,代码行数:57,代码来源:Profile.cpp

示例3: round

void
Profile::addIntersectingTiles(const GeoExtent& key_ext, unsigned localLOD, std::vector<TileKey>& out_intersectingKeys) const
{
    // assume a non-crossing extent here.
    if ( key_ext.crossesAntimeridian() )
    {
        OE_WARN << "Profile::addIntersectingTiles cannot process date-line cross" << std::endl;
        return;
    }

    int tileMinX, tileMaxX;
    int tileMinY, tileMaxY;

    // Special path for mercator (does NOT work for cube, e.g.)
    if ( key_ext.getSRS()->isMercator() )
    {
        int precision = 5;
        double eps = 0.001;

        double keyWidth = round(key_ext.width(), precision);
        int destLOD = 0;
        double w, h;
        getTileDimensions(0, w, h);
        for(; (round(w,precision) - keyWidth) > eps; w*=0.5, h*=0.5, destLOD++ );

        double destTileWidth, destTileHeight;
        getTileDimensions( destLOD, destTileWidth, destTileHeight );
        destTileWidth = round(destTileWidth, precision);
        destTileHeight = round(destTileHeight, precision);

        tileMinX = quantize( ((key_ext.xMin() - _extent.xMin()) / destTileWidth), eps );
        tileMaxX = (int)((key_ext.xMax() - _extent.xMin()) / destTileWidth);

        tileMinY = quantize( ((_extent.yMax() - key_ext.yMax()) / destTileHeight), eps );
        tileMaxY = (int) ((_extent.yMax() - key_ext.yMin()) / destTileHeight);
    }

    else
    {
        double destTileWidth, destTileHeight;
        getTileDimensions(localLOD, destTileWidth, destTileHeight);

        //OE_DEBUG << std::fixed << "  Source Tile: " << key.getLevelOfDetail() << " (" << keyWidth << ", " << keyHeight << ")" << std::endl;
        //OE_DEBUG << std::fixed << "  Dest Size: " << destLOD << " (" << destTileWidth << ", " << destTileHeight << ")" << std::endl;

        tileMinX = (int)((key_ext.xMin() - _extent.xMin()) / destTileWidth);
        tileMaxX = (int)((key_ext.xMax() - _extent.xMin()) / destTileWidth);

        tileMinY = (int)((_extent.yMax() - key_ext.yMax()) / destTileHeight);
        tileMaxY = (int)((_extent.yMax() - key_ext.yMin()) / destTileHeight);
    }

    unsigned int numWide, numHigh;
    getNumTiles(localLOD, numWide, numHigh);

    // bail out if the tiles are out of bounds.
    if ( tileMinX >= (int)numWide || tileMinY >= (int)numHigh ||
            tileMaxX < 0 || tileMaxY < 0 )
    {
        return;
    }

    tileMinX = osg::clampBetween(tileMinX, 0, (int)numWide-1);
    tileMaxX = osg::clampBetween(tileMaxX, 0, (int)numWide-1);
    tileMinY = osg::clampBetween(tileMinY, 0, (int)numHigh-1);
    tileMaxY = osg::clampBetween(tileMaxY, 0, (int)numHigh-1);

    OE_DEBUG << std::fixed << "  Dest Tiles: " << tileMinX << "," << tileMinY << " => " << tileMaxX << "," << tileMaxY << std::endl;

    for (int i = tileMinX; i <= tileMaxX; ++i)
    {
        for (int j = tileMinY; j <= tileMaxY; ++j)
        {
            //TODO: does not support multi-face destination keys.
            out_intersectingKeys.push_back( TileKey(localLOD, i, j, this) );
        }
    }
}
开发者ID:aurelien35,项目名称:osgearth,代码行数:78,代码来源:Profile.cpp

示例4: ext

*/

#include <osgEarth/catch.hpp>

#include <osgEarth/GeoData>

using namespace osgEarth;

TEST_CASE( "GeoExtent" ) {
    
    const SpatialReference* WGS84 = SpatialReference::get("wgs84");
    const SpatialReference* CUBE = SpatialReference::get("unified-cube");
    
    SECTION("Create an extent that crosses the antimeridian") {
        GeoExtent ext(SpatialReference::create("wgs84"), 178, 30, 183.4, 34.5);
        REQUIRE(ext.crossesAntimeridian());
    
        // Transform it and make sure it still crosses the antimeridian.
        GeoExtent transformed;
        ext.transform(SpatialReference::create("wgs84"), transformed);
        REQUIRE(transformed.crossesAntimeridian());
    }

    SECTION("GeoExtent contains simple") {
        GeoExtent ext(WGS84, -10.0, -10.0, 10.0, 10.0);
        REQUIRE(ext.contains(5.0, 5.0));
    }

    SECTION( "GeoExtent contains works when the extent cross the antimeridian" ) {
        GeoExtent ext(WGS84, -180.001, -90.0, 179.995, 90.0);
        REQUIRE(ext.contains(5.0, 0.0));
开发者ID:pprabhu78,项目名称:osgearth,代码行数:31,代码来源:GeoExtentTests.cpp

示例5: round

void
Profile::addIntersectingTiles(const GeoExtent& key_ext, std::vector<TileKey>& out_intersectingKeys) const
{
    // assume a non-crossing extent here.
    if ( key_ext.crossesAntimeridian() )
    {
        OE_WARN << "Profile::addIntersectingTiles cannot process date-line cross" << std::endl;
        return;
    }

#if 0 // works for meracator; does NOT work for cube

    int precision = 5;
    double eps = 0.001;

    double keyWidth = round(key_ext.width(), precision);
    int destLOD = 0;
    double w, h;
    getTileDimensions(0, w, h);
    for(; (round(w,precision) - keyWidth) > eps; w*=0.5, h*=0.5, destLOD++ );

    double destTileWidth, destTileHeight;
    getTileDimensions( destLOD, destTileWidth, destTileHeight );
    destTileWidth = round(destTileWidth, precision);
    destTileHeight = round(destTileHeight, precision);

    int tileMinX = quantize( ((key_ext.xMin() - _extent.xMin()) / destTileWidth), eps );
    int tileMaxX = (int)((key_ext.xMax() - _extent.xMin()) / destTileWidth);

    int tileMinY = quantize( ((_extent.yMax() - key_ext.yMax()) / destTileHeight), eps );
    int tileMaxY = (int) ((_extent.yMax() - key_ext.yMin()) / destTileHeight);

#else

    double keyWidth = key_ext.width();
    double keyHeight = key_ext.height();

    // bail out if the key has a null extent. This might happen is the original key represents an
    // area in one profile that is out of bounds in this profile.
    if ( keyWidth <= 0.0 && keyHeight <= 0.0 )
        return;

    double keySpan = std::min( keyWidth, keyHeight );
    double keyArea = keyWidth * keyHeight;
    double keyAvg  = 0.5*(keyWidth+keyHeight);

    int destLOD = 1;
    double destTileWidth, destTileHeight;

    int currLOD = 0;
    destLOD = currLOD;
    getTileDimensions(destLOD, destTileWidth, destTileHeight);

    while( true )
    {
        currLOD++;
        double w, h;
        getTileDimensions(currLOD, w, h);
        
        if ( w < keyAvg || h < keyAvg ) break;
        destLOD = currLOD;
        destTileWidth = w;
        destTileHeight = h;
    }


    //OE_DEBUG << std::fixed << "  Source Tile: " << key.getLevelOfDetail() << " (" << keyWidth << ", " << keyHeight << ")" << std::endl;
    //OE_DEBUG << std::fixed << "  Dest Size: " << destLOD << " (" << destTileWidth << ", " << destTileHeight << ")" << std::endl;

    int tileMinX = (int)((key_ext.xMin() - _extent.xMin()) / destTileWidth);
    int tileMaxX = (int)((key_ext.xMax() - _extent.xMin()) / destTileWidth);

    int tileMinY = (int)((_extent.yMax() - key_ext.yMax()) / destTileHeight); 
    int tileMaxY = (int)((_extent.yMax() - key_ext.yMin()) / destTileHeight); 
#endif

    unsigned int numWide, numHigh;
    getNumTiles(destLOD, numWide, numHigh);

    // bail out if the tiles are out of bounds.
    if ( tileMinX >= (int)numWide || tileMinY >= (int)numHigh ||
         tileMaxX < 0 || tileMaxY < 0 )
    {
        return;
    }

    tileMinX = osg::clampBetween(tileMinX, 0, (int)numWide-1);
    tileMaxX = osg::clampBetween(tileMaxX, 0, (int)numWide-1);
    tileMinY = osg::clampBetween(tileMinY, 0, (int)numHigh-1);
    tileMaxY = osg::clampBetween(tileMaxY, 0, (int)numHigh-1);

    OE_DEBUG << std::fixed << "  Dest Tiles: " << tileMinX << "," << tileMinY << " => " << tileMaxX << "," << tileMaxY << std::endl;

    for (int i = tileMinX; i <= tileMaxX; ++i)
    {
        for (int j = tileMinY; j <= tileMaxY; ++j)
        {
            //TODO: does not support multi-face destination keys.
            out_intersectingKeys.push_back( TileKey(destLOD, i, j, this) );
        }
//.........这里部分代码省略.........
开发者ID:Sylla,项目名称:osgearth,代码行数:101,代码来源:Profile.cpp


注:本文中的GeoExtent::crossesAntimeridian方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。