Пример #1
0
 tagged_tuple<tag::in1(I0), tag::in2(I1), tag::out(O)> operator()(I0 begin0, S0 end0, I1 begin1, S1 end1, O out, F fun_,
     P0 proj0_ = P0{}, P1 proj1_ = P1{}) const
 {
     auto &&fun = as_function(fun_);
     auto &&proj0 = as_function(proj0_);
     auto &&proj1 = as_function(proj1_);
     for(; begin0 != end0 && begin1 != end1; ++begin0, ++begin1, ++out)
         *out = fun(proj0(*begin0), proj1(*begin1));
     return tagged_tuple<tag::in1(I0), tag::in2(I1), tag::out(O)>{begin0, begin1, out};
 }
Пример #2
0
 std::tuple<I0, I1, O> operator()(I0 begin0, S0 end0, I1 begin1, S1 end1, O out, F fun_,
     P0 proj0_ = P0{}, P1 proj1_ = P1{}) const
 {
     auto &&fun = as_function(fun_);
     auto &&proj0 = as_function(proj0_);
     auto &&proj1 = as_function(proj1_);
     for(; begin0 != end0 && begin1 != end1; ++begin0, ++begin1, ++out)
         *out = fun(proj0(*begin0), proj1(*begin1));
     return std::tuple<I0, I1, O>{begin0, begin1, out};
 }
Пример #3
0
 bool nocheck(I0 begin0, S0 end0, I1 begin1, S1 end1, C pred_,
     P0 proj0_, P1 proj1_) const
 {
     auto &&pred = as_function(pred_);
     auto &&proj0 = as_function(proj0_);
     auto &&proj1 = as_function(proj1_);
     for(; begin0 != end0 && begin1 != end1; ++begin0, ++begin1)
         if(!pred(proj0(*begin0), proj1(*begin1)))
             return false;
     return begin0 == end0 && begin1 == end1;
 }
Пример #4
0
 bool operator()(I0 begin0, S0 end0, I1 begin1, S1 end1, C pred_ = C{}, P0 proj0_ = P0{},
     P1 proj1_ = P1{}) const
 {
     auto &&pred = invokable(pred_);
     auto &&proj0 = invokable(proj0_);
     auto &&proj1 = invokable(proj1_);
     for(; begin1 != end1; ++begin0, ++begin1)
     {
         if(begin0 == end0 || pred(proj0(*begin0), proj1(*begin1)))
             return true;
         if(pred(proj1(*begin1), proj1(*begin0)))
             return false;
     }
     return false;
 }
Пример #5
0
 std::tuple<I0, I1, O>
 operator()(I0 begin0, S0 end0, I1 begin1, S1 end1, O out, C pred_ = C{},
     P0 proj0_ = P0{}, P1 proj1_ = P1{}) const
 {
     auto &&pred = as_function(pred_);
     auto &&proj0 = as_function(proj0_);
     auto &&proj1 = as_function(proj1_);
     for(; begin0 != end0 && begin1 != end1; ++out)
     {
         if(pred(proj1(*begin1), proj0(*begin0)))
         {
             *out = iter_move(begin1);
             ++begin1;
         }
         else
         {
             *out = iter_move(begin0);
             ++begin0;
         }
     }
     auto t0 = move(begin0, end0, out);
     auto t1 = move(begin1, end1, t0.second);
     return std::tuple<I0, I1, O>{t0.first, t1.first, t1.second};
 }
Пример #6
0
void Map::zoom_all()
{
    try
    {
        if (layers_.empty())
        {
            return;
        }
        projection proj0(srs_);
        box2d<double> ext;
        bool success = false;
        bool first = true;
        std::vector<layer>::const_iterator itr = layers_.begin();
        std::vector<layer>::const_iterator end = layers_.end();
        while (itr != end)
        {
            if (itr->active())
            {
                std::string const& layer_srs = itr->srs();
                projection proj1(layer_srs);
                proj_transform prj_trans(proj0,proj1);
                box2d<double> layer_ext = itr->envelope();
                if (prj_trans.backward(layer_ext, PROJ_ENVELOPE_POINTS))
                {
                    success = true;
                    MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " original ext=" << itr->envelope();
                    MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " transformed to map srs=" << layer_ext;
                    if (first)
                    {
                        ext = layer_ext;
                        first = false;
                    }
                    else
                    {
                        ext.expand_to_include(layer_ext);
                    }
                }
            }
            ++itr;
        }
        if (success)
        {
            if (maximum_extent_) {
                ext.clip(*maximum_extent_);
            }
            zoom_to_box(ext);
        }
        else
        {
            if (maximum_extent_)
            {
                MAPNIK_LOG_ERROR(map) << "could not zoom to combined layer extents"
                    << " so falling back to maximum-extent for zoom_all result";
                zoom_to_box(*maximum_extent_);
            }
            else
            {
                std::ostringstream s;
                s << "could not zoom to combined layer extents "
                  << "using zoom_all because proj4 could not "
                  << "back project any layer extents into the map srs "
                  << "(set map 'maximum-extent' to override layer extents)";
                throw std::runtime_error(s.str());
            }
        }
    }
    catch (proj_init_error const& ex)
    {
        throw mapnik::config_error(std::string("Projection error during map.zoom_all: ") + ex.what());
    }
}
Пример #7
0
void Map::zoom_all() 
{
    if (maximum_extent_) {
        zoom_to_box(*maximum_extent_);
    }
    else
    {
        try 
        {
            if (!layers_.size() > 0)
                return;
            projection proj0(srs_);
            box2d<double> ext;
            bool success = false;
            bool first = true;
            std::vector<layer>::const_iterator itr = layers_.begin();
            std::vector<layer>::const_iterator end = layers_.end();
            while (itr != end)
            {
                if (itr->isActive())
                {
                    std::string const& layer_srs = itr->srs();
                    projection proj1(layer_srs);
                    
                    proj_transform prj_trans(proj0,proj1);
                        
                    box2d<double> layer_ext = itr->envelope();
                    // TODO - consider using more robust method: http://trac.mapnik.org/ticket/751
                    if (prj_trans.backward(layer_ext))
                    {
                        success = true;
            #ifdef MAPNIK_DEBUG
                        std::clog << " layer " << itr->name() << " original ext: " << itr->envelope() << "\n";
                        std::clog << " layer " << itr->name() << " transformed to map srs: " << layer_ext << "\n";
            #endif                
                        if (first)
                        {
                            ext = layer_ext;
                            first = false;
                        }
                        else 
                        {
                            ext.expand_to_include(layer_ext);
                        }
                    }
                }
                ++itr;
            }
            if (success) {
                zoom_to_box(ext);
            } else {
                std::ostringstream s;
                s << "could not zoom to combined layer extents "
                  << "using zoom_all because proj4 could not "
                  << "back project any layer extents into the map srs "
                  << "(set map 'maximum-extent' to override layer extents)";
                throw std::runtime_error(s.str());
            }
        }
        catch (proj_init_error & ex)
        {
            std::clog << "proj_init_error:" << ex.what() << "\n";
        }    
    }
}