Example #1
0
void RegionCASA::_getWorldVertices(std::vector<casa::Quantity>& x, std::vector<casa::Quantity>& y,
        const casa::CoordinateSystem& csys,
        const casa::Vector<casa::MDirection>& directions ) const {
    const casa::IPosition dirAxes = csys.directionAxesNumbers();
    casa::String xUnit = csys.worldAxisUnits()[dirAxes[0]];
    casa::String yUnit = csys.worldAxisUnits()[dirAxes[1]];
    int directionCount = directions.size();
    x.resize( directionCount );
    y.resize( directionCount );
    for (int i = 0; i < directionCount; i++) {
        x[i] = casa::Quantity(directions[i].getAngle(xUnit).getValue(xUnit)[0], xUnit);
        y[i] = casa::Quantity(directions[i].getAngle(yUnit).getValue(yUnit)[1], yUnit);
    }
}
Example #2
0
std::vector<std::pair<double,double> >
RegionCASA::_getPixelVertices( const casa::AnnotationBase::Direction& corners,
        const casa::CoordinateSystem& csys, const casa::Vector<casa::MDirection>& directions ) const {
    std::vector<casa::Quantity> xx, xy;
    _getWorldVertices(xx, xy, csys, directions );
    casa::Vector<casa::Double> world = csys.referenceValue();
    const casa::IPosition dirAxes = csys.directionAxesNumbers();
    casa::String xUnit = csys.worldAxisUnits()[dirAxes[0]];
    casa::String yUnit = csys.worldAxisUnits()[dirAxes[1]];
    int cornerCount = corners.size();

    std::vector<std::pair<double,double> > pixelVertices( cornerCount );
    for (int i=0; i<cornerCount; i++) {
        world[dirAxes[0]] = xx[i].getValue(xUnit);
        world[dirAxes[1]] = xy[i].getValue(yUnit);
        casa::Vector<casa::Double> pixel;
        csys.toPixel(pixel, world);
        pixelVertices[i]= std::pair<double,double>( pixel[dirAxes[0]], pixel[dirAxes[1]] );
    }
    return pixelVertices;
}