Exemplo n.º 1
0
static CPLString CPLEscapeURLQueryParameter( const char *pszInput )
{
    int nLength = static_cast<int>(strlen(pszInput));

    const size_t nSizeAlloc = nLength * 4 + 1;
    char *pszOutput = static_cast<char *>( CPLMalloc( nSizeAlloc ) );
    int iOut = 0;

    for( int iIn = 0; iIn < nLength; ++iIn )
    {
        if( (pszInput[iIn] >= 'a' && pszInput[iIn] <= 'z')
            || (pszInput[iIn] >= 'A' && pszInput[iIn] <= 'Z')
            || (pszInput[iIn] >= '0' && pszInput[iIn] <= '9') )
        {
            pszOutput[iOut++] = pszInput[iIn];
        }
        else
        {
            snprintf( pszOutput+iOut, nSizeAlloc - iOut, "%%%02X",
                        static_cast<unsigned char>( pszInput[iIn] ) );
            iOut += 3;
        }
    }
    pszOutput[iOut] = '\0';

    CPLString osRet(pszOutput);
    CPLFree(pszOutput);
    return osRet;
}
Exemplo n.º 2
0
CPLString OGRVRTGetSerializedGeometryType(OGRwkbGeometryType eGeomType)
{
    for( const auto& entry: asGeomTypeNames )
    {
        if( entry.eType == wkbFlatten(eGeomType) )
        {
            CPLString osRet(entry.pszName);
            if( entry.bIsoFlags || OGR_GT_HasM(eGeomType) )
            {
                if( OGR_GT_HasZ(eGeomType) )
                {
                    osRet += "Z";
                }
                if( OGR_GT_HasM(eGeomType) )
                {
                    osRet += "M";
                }
            }
            else if(OGR_GT_HasZ(eGeomType) )
            {
                osRet += "25D";
            }
            return osRet;
        }
    }
    return CPLString();
}
Exemplo n.º 3
0
static CPLString LaunderString(const char* pszStr)
{
    CPLString osRet(pszStr);
    for(size_t i=0;i<osRet.size();i++)
    {
        if( osRet[i] == ':' || osRet[i] == ' ' )
            osRet[i] = '_';
    }
    return osRet;
}