本文整理汇总了C++中mapnik::box2d::minx方法的典型用法代码示例。如果您正苦于以下问题:C++ box2d::minx方法的具体用法?C++ box2d::minx怎么用?C++ box2d::minx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapnik::box2d
的用法示例。
在下文中一共展示了box2d::minx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: features
featureset_ptr geos_datasource::features(query const& q) const
{
if (!is_bound_) bind();
const mapnik::box2d<double> extent = q.get_bbox();
std::ostringstream s;
s << "POLYGON(("
<< extent.minx() << " " << extent.miny() << ","
<< extent.maxx() << " " << extent.miny() << ","
<< extent.maxx() << " " << extent.maxy() << ","
<< extent.minx() << " " << extent.maxy() << ","
<< extent.minx() << " " << extent.miny()
<< "))";
#ifdef MAPNIK_DEBUG
clog << "GEOS Plugin: using extent: " << s.str() << endl;
#endif
return boost::make_shared<geos_featureset>(*geometry_,
GEOSGeomFromWKT(s.str().c_str()),
geometry_id_,
geometry_data_,
geometry_data_name_,
desc_.get_encoding(),
multiple_geometries_);
}
示例2: operator
bool operator()() const
{
mapnik::geometry::geometry<double> geom;
if (!mapnik::from_wkt(wkt_in_, geom))
{
throw std::runtime_error("Failed to parse WKT");
}
if (mapnik::geometry::is_empty(geom))
{
std::clog << "empty geom!\n";
return false;
}
if (!geom.is<mapnik::geometry::polygon<double> >())
{
std::clog << "not a polygon!\n";
return false;
}
mapnik::geometry::polygon<double> & poly = mapnik::util::get<mapnik::geometry::polygon<double> >(geom);
mapnik::geometry::correct(poly);
mapnik::geometry::linear_ring<double> bbox;
bbox.emplace_back(extent_.minx(), extent_.miny());
bbox.emplace_back(extent_.minx(), extent_.maxy());
bbox.emplace_back(extent_.maxx(), extent_.maxy());
bbox.emplace_back(extent_.maxx(), extent_.miny());
bbox.emplace_back(extent_.minx(), extent_.miny());
bool valid = true;
for (unsigned i=0;i<iterations_;++i)
{
std::deque<mapnik::geometry::polygon<double> > result;
boost::geometry::intersection(bbox, poly, result);
unsigned count = 0;
for (auto const& _geom : result)
{
mapnik::geometry::polygon_vertex_adapter<double> va(_geom);
unsigned cmd;
double x,y;
while ((cmd = va.vertex(&x, &y)) != mapnik::SEG_END) {
++count;
}
unsigned expected_count = 29;
if (count != expected_count) {
std::clog << "test3: clipping failed: processed " << count << " verticies but expected " << expected_count << "\n";
valid = false;
}
}
}
return valid;
}
示例3: validate
bool validate() const
{
mapnik::geometry::geometry<double> geom;
if (!mapnik::from_wkt(wkt_in_, geom))
{
throw std::runtime_error("Failed to parse WKT");
}
if (mapnik::geometry::is_empty(geom))
{
std::clog << "empty geom!\n";
return false;
}
if (!geom.is<mapnik::geometry::polygon<double> >())
{
std::clog << "not a polygon!\n";
return false;
}
mapnik::geometry::polygon<double> & poly = mapnik::util::get<mapnik::geometry::polygon<double> >(geom);
mapnik::geometry::correct(poly);
mapnik::geometry::linear_ring<double> bbox;
bbox.emplace_back(extent_.minx(), extent_.miny());
bbox.emplace_back(extent_.minx(), extent_.maxy());
bbox.emplace_back(extent_.maxx(), extent_.maxy());
bbox.emplace_back(extent_.maxx(), extent_.miny());
bbox.emplace_back(extent_.minx(), extent_.miny());
std::deque<mapnik::geometry::polygon<double> > result;
boost::geometry::intersection(bbox, poly, result);
std::string expect = expected_+".png";
std::string actual = expected_+"_actual.png";
mapnik::geometry::multi_polygon<double> mp;
for (auto const& _geom: result)
{
//std::clog << boost::geometry::dsv(geom) << "\n";
mp.emplace_back(_geom);
}
mapnik::geometry::geometry<double> geom2(mp);
auto env = mapnik::geometry::envelope(geom2);
if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr))
{
std::clog << "generating expected image: " << expect << "\n";
render(mp,env,expect);
}
render(mp,env,actual);
return benchmark::compare_images(actual,expect);
}
示例4: apply_spatial_filter
static bool apply_spatial_filter(std::string & query,
mapnik::box2d<double> const& e,
std::string const& table,
std::string const& key_field,
std::string const& index_table,
std::string const& geometry_table,
std::string const& intersects_token)
{
std::ostringstream spatial_sql;
spatial_sql << std::setprecision(16);
spatial_sql << key_field << " IN (SELECT pkid FROM " << index_table;
spatial_sql << " WHERE xmax>=" << e.minx() << " AND xmin<=" << e.maxx() ;
spatial_sql << " AND ymax>=" << e.miny() << " AND ymin<=" << e.maxy() << ")";
if (boost::algorithm::ifind_first(query, intersects_token))
{
boost::algorithm::ireplace_all(query, intersects_token, spatial_sql.str());
return true;
}
// substitute first WHERE found if not using JOIN
// (because we can't know the WHERE is on the right table)
else if (boost::algorithm::ifind_first(query, "WHERE")
&& !boost::algorithm::ifind_first(query, "JOIN"))
{
std::string replace(" WHERE " + spatial_sql.str() + " AND ");
boost::algorithm::ireplace_first(query, "WHERE", replace);
return true;
}
// fallback to appending spatial filter at end of query
else if (boost::algorithm::ifind_first(query, geometry_table))
{
query = table + " WHERE " + spatial_sql.str();
return true;
}
return false;
}
示例5: operator
void operator()() const
{
boost::ptr_vector<mapnik::geometry_type> paths;
if (!mapnik::from_wkt(wkt_in_, paths))
{
throw std::runtime_error("Failed to parse WKT");
}
agg::path_storage ps;
ps.move_to(extent_.minx(), extent_.miny());
ps.line_to(extent_.minx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.miny());
ps.close_polygon();
for (unsigned i=0;i<iterations_;++i)
{
for (mapnik::geometry_type & geom : paths)
{
poly_clipper clipped(geom,ps,
agg::clipper_and,
agg::clipper_non_zero,
agg::clipper_non_zero,
1);
clipped.rewind(0);
unsigned cmd;
double x,y;
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END) {}
}
}
}
示例6:
static jobject box2dFromNative(JNIEnv *env, mapnik::box2d<double> const& box) {
jobject ret=env->AllocObject(CLASS_BOX2D);
env->SetDoubleField(ret, FIELD_BOX2D_MINX, box.minx());
env->SetDoubleField(ret, FIELD_BOX2D_MINY, box.miny());
env->SetDoubleField(ret, FIELD_BOX2D_MAXX, box.maxx());
env->SetDoubleField(ret, FIELD_BOX2D_MAXY, box.maxy());
return ret;
}
示例7: clip_line
std::string clip_line(mapnik::box2d<double> const& bbox,
mapnik::geometry_type & geom)
{
using line_clipper = agg::conv_clip_polyline<mapnik::geometry_type>;
line_clipper clipped(geom);
clipped.clip_box(bbox.minx(),bbox.miny(),bbox.maxx(),bbox.maxy());
return dump_path(clipped);
}
示例8: clip_line
std::string clip_line(mapnik::box2d<double> const& bbox,
mapnik::path_type const& path)
{
using line_clipper = agg::conv_clip_polyline<mapnik::vertex_adapter>;
mapnik::vertex_adapter va(path);
line_clipper clipped(va);
clipped.clip_box(bbox.minx(),bbox.miny(),bbox.maxx(),bbox.maxy());
return dump_path(clipped);
}
示例9: bind
void bind(mapnik::box2d<double> const& bbox)
{
if ((sqlite3_bind_double(stmt_, 2, bbox.minx()) != SQLITE_OK) ||
(sqlite3_bind_double(stmt_, 3, bbox.maxx()) != SQLITE_OK) ||
(sqlite3_bind_double(stmt_, 4, bbox.miny()) != SQLITE_OK) ||
(sqlite3_bind_double(stmt_, 5, bbox.maxy()) != SQLITE_OK))
{
throw mapnik::datasource_exception("SQLite Plugin: invalid value for for extent while generating index");
}
}
示例10: validate
bool validate() const
{
mapnik::projection src(src_,defer_proj4_init_);
mapnik::projection dest(dest_,defer_proj4_init_);
mapnik::proj_transform tr(src,dest);
mapnik::box2d<double> bbox = from_;
if (!tr.forward(bbox)) return false;
return ((std::fabs(bbox.minx() - to_.minx()) < .5) &&
(std::fabs(bbox.maxx() - to_.maxx()) < .5) &&
(std::fabs(bbox.miny() - to_.miny()) < .5) &&
(std::fabs(bbox.maxy() - to_.maxy()) < .5)
);
}
示例11: operator
bool operator()() const
{
mapnik::geometry::geometry<double> geom;
if (!mapnik::from_wkt(wkt_in_, geom))
{
throw std::runtime_error("Failed to parse WKT");
}
if (mapnik::geometry::is_empty(geom))
{
std::clog << "empty geom!\n";
return false;
}
if (!geom.is<mapnik::geometry::polygon<double>>())
{
std::clog << "not a polygon!\n";
return false;
}
mapnik::geometry::polygon<double> const& poly = mapnik::util::get<mapnik::geometry::polygon<double>>(geom);
agg::path_storage ps;
ps.move_to(extent_.minx(), extent_.miny());
ps.line_to(extent_.minx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.miny());
ps.close_polygon();
bool valid = true;
for (unsigned i=0;i<iterations_;++i)
{
unsigned count = 0;
mapnik::geometry::polygon_vertex_adapter<double> va(poly);
poly_clipper clipped(va,ps,
agg::clipper_and,
agg::clipper_non_zero,
agg::clipper_non_zero,
1);
clipped.rewind(0);
unsigned cmd;
double x,y;
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END) {
count++;
}
unsigned expected_count = 31;
if (count != expected_count) {
std::clog << "test2: clipping failed: processed " << count << " verticies but expected " << expected_count << "\n";
valid = false;
}
}
return valid;
}
示例12: transcoder
ogr_featureset::ogr_featureset(mapnik::context_ptr const& ctx,
OGRLayer & layer,
mapnik::box2d<double> const& extent,
std::string const& encoding)
: ctx_(ctx),
layer_(layer),
layerdef_(layer.GetLayerDefn()),
tr_(new transcoder(encoding)),
fidcolumn_(layer_.GetFIDColumn()), // TODO - unused
count_(0)
{
layer_.SetSpatialFilterRect (extent.minx(),
extent.miny(),
extent.maxx(),
extent.maxy());
}
示例13: validate
bool validate() const
{
std::string expected_wkt("Polygon((212 134,329 138,394 229,528 178,631 234.4,631 321.3,559 466,463 324,421 446,315 340,233 454,181 286.7,181 238.2,200 264,183 228),(313 190,229 191,249 334,343 287,405 378,455 262,553 397,613 263,533 237,510 305,470 248,440 256))");
boost::ptr_vector<mapnik::geometry_type> paths;
if (!mapnik::from_wkt(wkt_in_, paths))
{
throw std::runtime_error("Failed to parse WKT");
}
agg::path_storage ps;
ps.move_to(extent_.minx(), extent_.miny());
ps.line_to(extent_.minx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.miny());
ps.close_polygon();
if (paths.size() != 1)
{
std::clog << "paths.size() != 1\n";
return false;
}
mapnik::geometry_type const& geom = paths[0];
mapnik::vertex_adapter va(geom);
poly_clipper clipped(va,ps,
agg::clipper_and,
agg::clipper_non_zero,
agg::clipper_non_zero,
1);
clipped.rewind(0);
unsigned cmd;
double x,y;
mapnik::geometry_type geom2(mapnik::geometry_type::types::Polygon);
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END) {
geom2.push_vertex(x,y,(mapnik::CommandType)cmd);
}
std::string expect = expected_+".png";
std::string actual = expected_+"_actual.png";
auto env = mapnik::envelope(geom);
if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr))
{
std::clog << "generating expected image: " << expect << "\n";
render(geom2,env,expect);
}
render(geom2,env,actual);
return benchmark::compare_images(actual,expect);
}
示例14: operator
bool operator()() const
{
boost::ptr_vector<mapnik::geometry_type> paths;
if (!mapnik::from_wkt(wkt_in_, paths))
{
throw std::runtime_error("Failed to parse WKT");
}
agg::path_storage ps;
ps.move_to(extent_.minx(), extent_.miny());
ps.line_to(extent_.minx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.miny());
ps.close_polygon();
bool valid = true;
for (unsigned i=0;i<iterations_;++i)
{
unsigned count = 0;
for (mapnik::geometry_type const& geom : paths)
{
mapnik::vertex_adapter va(geom);
poly_clipper clipped(va,ps,
agg::clipper_and,
agg::clipper_non_zero,
agg::clipper_non_zero,
1);
clipped.rewind(0);
unsigned cmd;
double x,y;
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END) {
count++;
}
}
unsigned expected_count = 29;
if (count != expected_count) {
std::clog << "test1: clipping failed: processed " << count << " verticies but expected " << expected_count << "\n";
valid = false;
}
}
return valid;
}
示例15: bboxToXYZ
std::vector<unsigned> bboxToXYZ(mapnik::box2d<double> const& bboxCoords)
{
double minx = bboxCoords.minx();
double miny = bboxCoords.miny();
double maxx = bboxCoords.maxx();
double maxy = bboxCoords.maxy();
mapnik::merc2lonlat(&minx,&miny,1);
mapnik::merc2lonlat(&maxx,&maxy,1);
std::vector<double> ubbox = {
minx,
miny,
maxx,
maxy
};
unsigned z = getBboxZoom(ubbox);
if (z == 0) return {0, 0, 0};
minx = pointToTile(minx, miny, 32)[0];
miny = pointToTile(minx, miny, 32)[1];
unsigned x = static_cast<unsigned>(minx);
unsigned y = static_cast<unsigned>(miny);
return {x, y, z};
}