Ejemplo n.º 1
0
 inline box2d<double> transform(box2d<double>& box) const
 {
     int x_offset = int(std::floor(box.minx() / tile_size_));
     int y_offset = int(std::floor(box.miny() / tile_size_));
     box2d<double> rem(x_offset * tile_size_,
                       y_offset * tile_size_,
                       x_offset * tile_size_,
                       y_offset * tile_size_);
     box.init(box.minx() - rem.minx(),
              box.miny() - rem.miny(),
              box.maxx() - rem.maxx(),
              box.maxy() - rem.maxy());
     return rem;
 }
Ejemplo n.º 2
0
// Output is centered around (0,0)
static void rotated_box2d(box2d<double> & box, rotation const& rot, pixel_position const& center, double width, double height)
{
    double half_width, half_height;
    if (rot.sin == 0 && rot.cos == 1.)
    {
        half_width  = width / 2.;
        half_height = height / 2.;
    }
    else
    {
        half_width  = (width * rot.cos + height * rot.sin) /2.;
        half_height = (width * rot.sin + height * rot.cos) /2.;
    }
    box.init(center.x - half_width, center.y - half_height, center.x + half_width, center.y + half_height);
}
Ejemplo n.º 3
0
    inline void read_envelope(box2d<double>& envelope)
    {
#ifndef MAPNIK_BIG_ENDIAN
        file_.read(reinterpret_cast<char*>(&envelope), sizeof(envelope));
#else
        char data[4 * 8];
        file_.read(data,4 * 8);
        double minx, miny, maxx, maxy;
        read_double_ndr(data + 0 * 8, minx);
        read_double_ndr(data + 1 * 8, miny);
        read_double_ndr(data + 2 * 8, maxx);
        read_double_ndr(data + 3 * 8, maxy);
        envelope.init(minx, miny, maxx, maxy);
#endif
    }
Ejemplo n.º 4
0
bool proj_transform::backward (box2d<double> & box) const
{
    if (is_source_equal_dest_)
        return true;

    double minx = box.minx();
    double miny = box.miny();
    double maxx = box.maxx();
    double maxy = box.maxy();
    double z = 0.0;
    if (!backward(minx,miny,z))
        return false;
    if (!backward(maxx,maxy,z))
        return false;
    box.init(minx,miny,maxx,maxy);
    return true;
}