/************************************************************************/ /* OGRFromOGCGeomType() */ /************************************************************************/ /** Map OGCgeometry format type to corresponding OGR constants. * @param pszGeomType POINT[ ][Z][M], LINESTRING[ ][Z][M], etc... * @return OGR constant. */ OGRwkbGeometryType OGRFromOGCGeomType( const char *pszGeomType ) { OGRwkbGeometryType eType = wkbUnknown; bool bConvertTo3D = false; bool bIsMeasured = false; if( *pszGeomType != '\0' ) { char ch = pszGeomType[strlen(pszGeomType)-1]; if( ch == 'm' || ch == 'M' ) { bIsMeasured = true; if( strlen(pszGeomType) > 1 ) ch = pszGeomType[strlen(pszGeomType)-2]; } if( ch == 'z' || ch == 'Z' ) { bConvertTo3D = true; } } if( STARTS_WITH_CI(pszGeomType, "POINT") ) eType = wkbPoint; else if( STARTS_WITH_CI(pszGeomType, "LINESTRING") ) eType = wkbLineString; else if( STARTS_WITH_CI(pszGeomType, "POLYGON") ) eType = wkbPolygon; else if( STARTS_WITH_CI(pszGeomType, "MULTIPOINT") ) eType = wkbMultiPoint; else if( STARTS_WITH_CI(pszGeomType, "MULTILINESTRING") ) eType = wkbMultiLineString; else if( STARTS_WITH_CI(pszGeomType, "MULTIPOLYGON") ) eType = wkbMultiPolygon; else if( STARTS_WITH_CI(pszGeomType, "GEOMETRYCOLLECTION") ) eType = wkbGeometryCollection; else if( STARTS_WITH_CI(pszGeomType, "CIRCULARSTRING") ) eType = wkbCircularString; else if( STARTS_WITH_CI(pszGeomType, "COMPOUNDCURVE") ) eType = wkbCompoundCurve; else if( STARTS_WITH_CI(pszGeomType, "CURVEPOLYGON") ) eType = wkbCurvePolygon; else if( STARTS_WITH_CI(pszGeomType, "MULTICURVE") ) eType = wkbMultiCurve; else if( STARTS_WITH_CI(pszGeomType, "MULTISURFACE") ) eType = wkbMultiSurface; else if ( STARTS_WITH_CI(pszGeomType, "TRIANGLE") ) eType = wkbTriangle; else if ( STARTS_WITH_CI(pszGeomType, "POLYHEDRALSURFACE") ) eType = wkbPolyhedralSurface; else if ( STARTS_WITH_CI(pszGeomType, "TIN") ) eType = wkbTIN; else if ( STARTS_WITH_CI(pszGeomType, "CURVE") ) eType = wkbCurve; else if( STARTS_WITH_CI(pszGeomType, "SURFACE") ) eType = wkbSurface; else eType = wkbUnknown; if( bConvertTo3D ) eType = wkbSetZ(eType); if( bIsMeasured ) eType = wkbSetM(eType); return eType; }
----------------
/************************************************************************/ /* OGRToOGCGeomType() */ /************************************************************************/ /** Map OGR geometry format constants to corresponding OGC geometry type. * @param eGeomType OGR geometry type * @return string with OGC geometry type (without dimensionality) */ const char * OGRToOGCGeomType( OGRwkbGeometryType eGeomType ) { switch( wkbFlatten(eGeomType) ) { case wkbUnknown: return "GEOMETRY"; case wkbPoint: return "POINT"; case wkbLineString: return "LINESTRING"; case wkbPolygon: return "POLYGON"; case wkbMultiPoint: return "MULTIPOINT"; case wkbMultiLineString: return "MULTILINESTRING"; case wkbMultiPolygon: return "MULTIPOLYGON"; case wkbGeometryCollection: return "GEOMETRYCOLLECTION"; case wkbCircularString: return "CIRCULARSTRING"; case wkbCompoundCurve: return "COMPOUNDCURVE"; case wkbCurvePolygon: return "CURVEPOLYGON"; case wkbMultiCurve: return "MULTICURVE"; case wkbMultiSurface: return "MULTISURFACE"; case wkbTriangle: return "TRIANGLE"; case wkbPolyhedralSurface: return "POLYHEDRALSURFACE"; case wkbTIN: return "TIN"; case wkbCurve: return "CURVE"; case wkbSurface: return "SURFACE"; default: return ""; } }
---------------------------------------
/************************************************************************/ /* OGRGeometryTypeToName() */ /************************************************************************/ /** * \brief Fetch a human readable name corresponding to an OGRwkbGeometryType * value. The returned value should not be modified, or freed by the * application. * * This function is C callable. * * @param eType the geometry type. * * @return internal human readable string, or NULL on failure. */ const char *OGRGeometryTypeToName( OGRwkbGeometryType eType ) { bool b3D = wkbHasZ(eType); bool bMeasured = wkbHasM(eType); switch( wkbFlatten(eType) ) { case wkbUnknown: if( b3D && bMeasured ) return "3D Measured Unknown (any)"; else if( b3D ) return "3D Unknown (any)"; else if( bMeasured ) return "Measured Unknown (any)"; else return "Unknown (any)"; case wkbPoint: if( b3D && bMeasured ) return "3D Measured Point"; else if( b3D ) return "3D Point"; else if( bMeasured ) return "Measured Point"; else return "Point"; case wkbLineString: if( b3D && bMeasured ) return "3D Measured Line String"; else if( b3D ) return "3D Line String"; else if( bMeasured ) return "Measured Line String"; else return "Line String"; case wkbPolygon: if( b3D && bMeasured ) return "3D Measured Polygon"; else if( b3D ) return "3D Polygon"; else if( bMeasured ) return "Measured Polygon"; else return "Polygon"; case wkbMultiPoint: if( b3D && bMeasured ) return "3D Measured Multi Point"; else if( b3D ) return "3D Multi Point"; else if( bMeasured ) return "Measured Multi Point"; else return "Multi Point"; case wkbMultiLineString: if( b3D && bMeasured ) return "3D Measured Multi Line String"; else if( b3D ) return "3D Multi Line String"; else if( bMeasured ) return "Measured Multi Line String"; else return "Multi Line String"; case wkbMultiPolygon: if( b3D && bMeasured ) return "3D Measured Multi Polygon"; else if( b3D ) return "3D Multi Polygon"; else if( bMeasured ) return "Measured Multi Polygon"; else return "Multi Polygon"; case wkbGeometryCollection: if( b3D && bMeasured ) return "3D Measured Geometry Collection"; else if( b3D ) return "3D Geometry Collection"; else if( bMeasured ) return "Measured Geometry Collection"; else return "Geometry Collection"; case wkbCircularString: if( b3D && bMeasured ) return "3D Measured Circular String"; else if( b3D ) return "3D Circular String"; else if( bMeasured ) return "Measured Circular String"; else return "Circular String"; case wkbCompoundCurve: if( b3D && bMeasured ) return "3D Measured Compound Curve"; else if( b3D ) return "3D Compound Curve"; else if( bMeasured ) return "Measured Compound Curve"; else return "Compound Curve"; case wkbCurvePolygon: if( b3D && bMeasured ) return "3D Measured Curve Polygon"; else if( b3D ) return "3D Curve Polygon"; else if( bMeasured ) return "Measured Curve Polygon"; else return "Curve Polygon"; case wkbMultiCurve: if( b3D && bMeasured ) return "3D Measured Multi Curve"; else if( b3D ) return "3D Multi Curve"; else if( bMeasured ) return "Measured Multi Curve"; else return "Multi Curve"; case wkbMultiSurface: if( b3D && bMeasured ) return "3D Measured Multi Surface"; else if( b3D ) return "3D Multi Surface"; else if( bMeasured ) return "Measured Multi Surface"; else return "Multi Surface"; case wkbCurve: if( b3D && bMeasured ) return "3D Measured Curve"; else if( b3D ) return "3D Curve"; else if( bMeasured ) return "Measured Curve"; else return "Curve"; case wkbSurface: if( b3D && bMeasured ) return "3D Measured Surface"; else if( b3D ) return "3D Surface"; else if( bMeasured ) return "Measured Surface"; else return "Surface"; case wkbTriangle: if (b3D && bMeasured) return "3D Measured Triangle"; else if (b3D) return "3D Triangle"; else if (bMeasured) return "Measured Triangle"; else return "Triangle"; case wkbPolyhedralSurface: if (b3D && bMeasured) return "3D Measured PolyhedralSurface"; else if (b3D) return "3D PolyhedralSurface"; else if (bMeasured) return "Measured PolyhedralSurface"; else return "PolyhedralSurface"; case wkbTIN: if (b3D && bMeasured) return "3D Measured TIN"; else if (b3D) return "3D TIN"; else if (bMeasured) return "Measured TIN"; else return "TIN"; case wkbNone: return "None"; default: { return CPLSPrintf("Unrecognized: %d", static_cast<int>(eType)); } } }
-------------------------------------------------
标签:case,return,几何,else,b3D,bMeasured,类型,Measured,GDAL From: https://www.cnblogs.com/gispathfinder/p/17021507.html