Ejemplo n.º 1
0
 inline void write_point(CoordTransform const& t, double x, double y, bool last = false)
 {
     double z = 0.0;
     t.backward(&x, &y);
     trans_->forward(x, y, z);
     *f_ << "["<<x<<","<<y<<"]";
     if (!last) {
         *f_ << ",";
     }
 }
Ejemplo n.º 2
0
featureset_ptr Map::query_map_point(unsigned index, double x, double y) const
{
    if ( index< layers_.size())
    {
        mapnik::layer const& layer = layers_[index];
        CoordTransform tr = view_transform();
        tr.backward(&x,&y);

        try
        {
            mapnik::projection dest(srs_);
            mapnik::projection source(layer.srs());
            proj_transform prj_trans(source,dest);
            double z = 0;
            prj_trans.backward(x,y,z);

            double minx = current_extent_.minx();
            double miny = current_extent_.miny();
            double maxx = current_extent_.maxx();
            double maxy = current_extent_.maxy();

            prj_trans.backward(minx,miny,z);
            prj_trans.backward(maxx,maxy,z);
            double tol = (maxx - minx) / width_ * 3;
            mapnik::datasource_ptr ds = layer.datasource();
            if (ds)
            {
#ifdef MAPNIK_DEBUG
                std::clog << " query at point tol = " << tol << " (" << x << "," << y << ")\n";
#endif
                featureset_ptr fs = ds->features_at_point(mapnik::coord2d(x,y));
                if (fs)
                    return boost::make_shared<filter_featureset<hit_test_filter> >(fs,
                                                                                   hit_test_filter(x,y,tol));
            }
        }
        catch (...)
        {
#ifdef MAPNIK_DEBUG
            std::clog << "exception caught in \"query_map_point\"\n";
#endif
        }
    }
    return featureset_ptr();
}
Ejemplo n.º 3
0
featureset_ptr Map::query_map_point(unsigned index, double x, double y) const
{
    CoordTransform tr = view_transform();
    tr.backward(&x,&y);
    return query_point(index,x,y);
}