Пример #1
0
Bounds
Geometry::getBounds() const
{
    Bounds bounds;
    for( const_iterator i = begin(); i != end(); ++i )
        bounds.expandBy( i->x(), i->y(), i->z() );
    return bounds;
}
Пример #2
0
Bounds
MultiGeometry::getBounds() const
{
    Bounds bounds;
    for( GeometryCollection::const_iterator i = _parts.begin(); i != _parts.end(); ++i )
    {
        bounds.expandBy( i->get()->getBounds() );
    }
    return bounds;
}
Пример #3
0
bool
CubeSpatialReference::transformExtentToMBR(const SpatialReference* to_srs,
                                           double&                 in_out_xmin,
                                           double&                 in_out_ymin,
                                           double&                 in_out_xmax,
                                           double&                 in_out_ymax ) const
{
    // input bounds:
    Bounds inBounds(in_out_xmin, in_out_ymin, in_out_xmax, in_out_ymax);

    Bounds outBounds;

    // for each CUBE face, find the intersection of the input bounds and that face.
    for (int face = 0; face < 6; ++face)
    {
        Bounds faceBounds( (double)(face), 0.0, (double)(face+1), 1.0);

        Bounds intersection = faceBounds.intersectionWith(inBounds);

        // if they intersect (with a non-zero area; abutting doesn't count in this case)
        // transform the intersection and include in the result.
        if (intersection.isValid() && intersection.area2d() > 0.0)
        {
            double
                xmin = intersection.xMin(), ymin = intersection.yMin(),
                xmax = intersection.xMax(), ymax = intersection.yMax();

            if (transformInFaceExtentToMBR(to_srs, face, xmin, ymin, xmax, ymax))
            {
                outBounds.expandBy(Bounds(xmin, ymin, xmax, ymax));
            }
        }
    }

    if (outBounds.valid())
    {
        in_out_xmin = outBounds.xMin();
        in_out_ymin = outBounds.yMin();
        in_out_xmax = outBounds.xMax();
        in_out_ymax = outBounds.yMax();
        return true;
    }
    else
    {
        return false;
    }
}