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


C++ query::variables方法代码示例

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


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

示例1: features_with_context


//.........这里部分代码省略.........
        else
        {
            // Always get a connection in synchronous mode
            conn = pool->borrowObject();
            if(!conn )
            {
                throw mapnik::datasource_exception("Postgis Plugin: Null connection");
            }
        }


        if (geometryColumn_.empty())
        {
            std::ostringstream s_error;
            s_error << "PostGIS: geometry name lookup failed for table '";

            if (! schema_.empty())
            {
                s_error << schema_ << ".";
            }
            s_error << geometry_table_
                    << "'. Please manually provide the 'geometry_field' parameter or add an entry "
                    << "in the geometry_columns for '";

            if (! schema_.empty())
            {
                s_error << schema_ << ".";
            }
            s_error << geometry_table_ << "'.";

            throw mapnik::datasource_exception(s_error.str());
        }

        std::ostringstream s;

        const double px_gw = 1.0 / std::get<0>(q.resolution());
        const double px_gh = 1.0 / std::get<1>(q.resolution());

        s << "SELECT ST_AsBinary(";

        if (simplify_geometries_) {
          s << "ST_Simplify(";
        }

        s << "\"" << geometryColumn_ << "\"";

        if (simplify_geometries_) {
          // 1/20 of pixel seems to be a good compromise to avoid
          // drop of collapsed polygons.
          // See https://github.com/mapnik/mapnik/issues/1639
          const double tolerance = std::min(px_gw, px_gh) / 20.0;
          s << ", " << tolerance << ")";
        }

        s << ") AS geom";

        mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
        std::set<std::string> const& props = q.property_names();
        std::set<std::string>::const_iterator pos = props.begin();
        std::set<std::string>::const_iterator end = props.end();

        if (! key_field_.empty())
        {
            mapnik::sql_utils::quote_attr(s, key_field_);
            ctx->push(key_field_);

            for (; pos != end; ++pos)
            {
                if (*pos != key_field_)
                {
                    mapnik::sql_utils::quote_attr(s, *pos);
                    ctx->push(*pos);
                }
            }
        }
        else
        {
            for (; pos != end; ++pos)
            {
                mapnik::sql_utils::quote_attr(s, *pos);
                ctx->push(*pos);
            }
        }

        std::string table_with_bbox = populate_tokens(table_, scale_denom, box, px_gw, px_gh, q.variables());

        s << " FROM " << table_with_bbox;

        if (row_limit_ > 0)
        {
            s << " LIMIT " << row_limit_;
        }

        std::shared_ptr<IResultSet> rs = get_resultset(conn, s.str(), pool, proc_ctx);
        return std::make_shared<postgis_featureset>(rs, ctx, desc_.get_encoding(), !key_field_.empty());

    }

    return featureset_ptr();
}
开发者ID:MapQuest,项目名称:mapnik,代码行数:101,代码来源:postgis_datasource.cpp

示例2: features_with_context


//.........这里部分代码省略.........
            s << "," << twkb_tolerance << ",true)";
            // ! ST_TWKB()
            s << "," << twkb_rounding << ") AS geom";
        }
        else
        {
            s << "SELECT ST_AsBinary(";
            if (simplify_geometries_)
            {
                s << "ST_Simplify(";
            }
            if (simplify_clip_resolution_ > 0.0 && simplify_clip_resolution_ > px_sz)
            {
                s << "ST_ClipByBox2D(";
            }
            if (simplify_geometries_ && simplify_snap_ratio_ > 0.0)
            {
                s<< "ST_SnapToGrid(";
            }

            // Geometry column!
            s << "\"" << geometryColumn_ << "\"";

            // ! ST_SnapToGrid()
            if (simplify_geometries_ && simplify_snap_ratio_ > 0.0)
            {
                const double tolerance = px_sz * simplify_snap_ratio_;
                s << "," << tolerance << ")";
            }

            // ! ST_ClipByBox2D()
            if (simplify_clip_resolution_ > 0.0 && simplify_clip_resolution_ > px_sz)
            {
                s << "," << sql_bbox(box) << ")";
            }

            // ! ST_Simplify()
            if (simplify_geometries_)
            {
                const double tolerance = px_sz * simplify_dp_ratio_;
                s << ", " << tolerance;
                // Add parameter to ST_Simplify to keep collapsed geometries
                if (simplify_dp_preserve_)
                {
                    s << ", true";
                }
                s << ")";
            }

            // ! ST_AsBinary()
            s << ") AS geom";
        }
        mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
        std::set<std::string> const& props = q.property_names();
        std::set<std::string>::const_iterator pos = props.begin();
        std::set<std::string>::const_iterator end = props.end();

        if (! key_field_.empty())
        {
            mapnik::sql_utils::quote_attr(s, key_field_);
            if (key_field_as_attribute_)
            {
                ctx->push(key_field_);
            }

            for (; pos != end; ++pos)
            {
                if (*pos != key_field_)
                {
                    mapnik::sql_utils::quote_attr(s, *pos);
                    ctx->push(*pos);
                }
            }
        }
        else
        {
            for (; pos != end; ++pos)
            {
                mapnik::sql_utils::quote_attr(s, *pos);
                ctx->push(*pos);
            }
        }

        std::string table_with_bbox = populate_tokens(table_, scale_denom, box, px_gw, px_gh, q.variables());

        s << " FROM " << table_with_bbox;

        if (row_limit_ > 0)
        {
            s << " LIMIT " << row_limit_;
        }

        std::shared_ptr<IResultSet> rs = get_resultset(conn, s.str(), pool, proc_ctx);
        return std::make_shared<postgis_featureset>(rs, ctx, desc_.get_encoding(), !key_field_.empty(),
                                                    key_field_as_attribute_, twkb_encoding_);

    }

    return mapnik::make_invalid_featureset();
}
开发者ID:cquest,项目名称:mapnik,代码行数:101,代码来源:postgis_datasource.cpp


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