示例#1
0
double OGR_G_Area( OGRGeometryH hGeom )

{
    VALIDATE_POINTER1( hGeom, "OGR_G_Area", 0 );

    double dfArea;

    OGRwkbGeometryType eType = wkbFlatten(((OGRGeometry *) hGeom)->getGeometryType());
    if( OGR_GT_IsSurface(eType) )
    {
        dfArea = ((OGRSurface *) hGeom)->get_Area();
    }
    else if( OGR_GT_IsCurve(eType) )
    {
        dfArea = ((OGRCurve *) hGeom)->get_Area();
    }
    else if( OGR_GT_IsSubClassOf(eType, wkbMultiSurface) ||
             eType == wkbGeometryCollection )
    {
        dfArea = ((OGRGeometryCollection *) hGeom)->get_Area();
    }
    else
    {
        CPLError( CE_Warning, CPLE_AppDefined,
                  "OGR_G_Area() called against non-surface geometry type." );

        dfArea = 0.0;
    }

    return dfArea;
}
示例#2
0
double OGRGeometryCollection::get_Area() const
{
    double dfArea = 0.0;
    for( auto&& poSubGeom: *this )
    {
        OGRwkbGeometryType eType = wkbFlatten(poSubGeom->getGeometryType());
        if( OGR_GT_IsSurface(eType) )
        {
            const OGRSurface *poSurface = poSubGeom->toSurface();
            dfArea += poSurface->get_Area();
        }
        else if( OGR_GT_IsCurve(eType) )
        {
            const OGRCurve *poCurve = poSubGeom->toCurve();
            dfArea += poCurve->get_Area();
        }
        else if( OGR_GT_IsSubClassOf(eType, wkbMultiSurface) ||
                eType == wkbGeometryCollection )
        {
            dfArea += poSubGeom->toGeometryCollection()->get_Area();
        }
    }

    return dfArea;
}
double OGRGeometryCollection::get_Area() const
{
    double dfArea = 0.0;
    for( int iGeom = 0; iGeom < nGeomCount; iGeom++ )
    {
        OGRGeometry* geom = papoGeoms[iGeom];
        OGRwkbGeometryType eType = wkbFlatten(geom->getGeometryType());
        if( OGR_GT_IsSurface(eType) )
        {
            dfArea += ((OGRSurface *) geom)->get_Area();
        }
        else if( OGR_GT_IsCurve(eType) )
        {
            dfArea += ((OGRCurve *) geom)->get_Area();
        }
        else if( OGR_GT_IsSubClassOf(eType, wkbMultiSurface) ||
                eType == wkbGeometryCollection )
        {
            dfArea += ((OGRGeometryCollection *) geom)->get_Area();
        }
    }

    return dfArea;
}
示例#4
0
OGRBoolean
OGRMultiSurface::isCompatibleSubType( OGRwkbGeometryType eGeomType ) const
{
    return OGR_GT_IsSurface(eGeomType);
}