ogrfeaturestyle.cpp
来自「在linux环境下」· C++ 代码 · 共 1,732 行 · 第 1/5 页
CPP
1,732 行
CSLDestroy(papszToken2); CSLDestroy(papszToken); return TRUE;}/****************************************************************************//* void OGRStyleTool::SetInternalInputUnitFromParam(char *pszString) *//* *//****************************************************************************/void OGRStyleTool::SetInternalInputUnitFromParam(char *pszString){ char *pszUnit; if (pszString == NULL) return; pszUnit = strstr(pszString,"g"); if (pszUnit) { SetUnit(OGRSTUGround); pszUnit[0]= '\0'; return; } pszUnit = strstr(pszString,"px"); if (pszUnit) { SetUnit(OGRSTUPixel); pszUnit[0]= '\0'; return; } pszUnit = strstr(pszString,"pt"); if (pszUnit) { SetUnit(OGRSTUPoints); pszUnit[0]= '\0'; return; } pszUnit = strstr(pszString,"mm"); if (pszUnit) { SetUnit(OGRSTUMM); pszUnit[0]= '\0'; return; } pszUnit = strstr(pszString,"cm"); if (pszUnit) { SetUnit(OGRSTUCM); pszUnit[0]= '\0'; return; } pszUnit = strstr(pszString,"in"); if (pszUnit) { SetUnit(OGRSTUInches); pszUnit[0]= '\0'; return; } SetUnit(OGRSTUMM);}/****************************************************************************//* double OGRStyleTool::ComputeWithUnit(double dfValue, *//* OGRSTUnitId eInputUnit) *//* *//* *//****************************************************************************/double OGRStyleTool::ComputeWithUnit(double dfValue, OGRSTUnitId eInputUnit){ OGRSTUnitId eOutputUnit = GetUnit(); double dfNewValue = dfValue; // dfValue in Meter; if (eOutputUnit == eInputUnit) return dfValue; switch (eInputUnit) { case OGRSTUGround: dfNewValue = dfValue / m_dfScale; break; case OGRSTUPixel: dfNewValue = dfValue / (72.0 * 39.37); break; case OGRSTUPoints: dfNewValue =dfValue / (72.0 * 39.37); break; case OGRSTUMM: dfNewValue = 0.001 * dfValue; break; case OGRSTUCM: dfNewValue = 0.01 * dfValue; break; case OGRSTUInches: dfNewValue = dfValue / 39.37; break; default: break; //imp } switch (eOutputUnit) { case OGRSTUGround: dfNewValue *= m_dfScale; break; case OGRSTUPixel: dfNewValue *= (72.0 * 39.37); break; case OGRSTUPoints: dfNewValue *= (72.0 * 39.37); break; case OGRSTUMM: dfNewValue *= 1000.0; break; case OGRSTUCM: dfNewValue *= 100.0; break; case OGRSTUInches: dfNewValue *= 39.37; break; default: break; // imp } return dfNewValue;}/****************************************************************************//* int OGRStyleTool::ComputeWithUnit(int nValue, OGRSTUnitId eUnit) *//* *//****************************************************************************/int OGRStyleTool::ComputeWithUnit(int nValue, OGRSTUnitId eUnit){ return (int) ComputeWithUnit((double )nValue, eUnit);}/****************************************************************************//* const char *OGRStyleTool::GetParamStr(OGRStyleParamId sStyleParam ,*//* OGRStyleValue sStyleValue, *//* GBool &bValueIsNull) *//* *//****************************************************************************/const char *OGRStyleTool::GetParamStr(OGRStyleParamId &sStyleParam , OGRStyleValue &sStyleValue, GBool &bValueIsNull){ Parse(); bValueIsNull = !sStyleValue.bValid; if (bValueIsNull == TRUE) return ""; switch (sStyleParam.eType) { // if sStyleParam.bGeoref == TRUE , need to convert to output value; case OGRSTypeString: return sStyleValue.pszValue; break; case OGRSTypeDouble: if (sStyleParam.bGeoref) return CPLSPrintf("%f",ComputeWithUnit(sStyleValue.dfValue, sStyleValue.eUnit)); else return CPLSPrintf("%f",sStyleValue.dfValue); break; case OGRSTypeInteger: if (sStyleParam.bGeoref) return CPLSPrintf("%d",ComputeWithUnit(sStyleValue.nValue, sStyleValue.eUnit)); else return CPLSPrintf("%d",sStyleValue.nValue); break; default: bValueIsNull = TRUE; return NULL; break; }}/****************************************************************************//* int OGRStyleTool::GetParamNum(OGRStyleParamId sStyleParam , *//* OGRStyleValue sStyleValue, *//* GBool &bValueIsNull) *//* *//****************************************************************************/int OGRStyleTool::GetParamNum(OGRStyleParamId &sStyleParam , OGRStyleValue &sStyleValue, GBool &bValueIsNull){ return (int)GetParamDbl(sStyleParam,sStyleValue,bValueIsNull);}/****************************************************************************//* double OGRStyleTool::GetParamDbl(OGRStyleParamId sStyleParam , *//* OGRStyleValue sStyleValue, *//* GBool &bValueIsNull) *//* *//****************************************************************************/double OGRStyleTool::GetParamDbl(OGRStyleParamId &sStyleParam , OGRStyleValue &sStyleValue, GBool &bValueIsNull){ Parse(); bValueIsNull = !sStyleValue.bValid; if (bValueIsNull == TRUE) return 0; switch (sStyleParam.eType) { // if sStyleParam.bGeoref == TRUE , need to convert to output value; case OGRSTypeString: if (sStyleParam.bGeoref) return ComputeWithUnit(atof(sStyleValue.pszValue), sStyleValue.eUnit); else return atof(sStyleValue.pszValue); break; case OGRSTypeDouble: if (sStyleParam.bGeoref) return ComputeWithUnit(sStyleValue.dfValue, sStyleValue.eUnit); else return sStyleValue.dfValue; break; case OGRSTypeInteger: if (sStyleParam.bGeoref) return (double)ComputeWithUnit(sStyleValue.nValue, sStyleValue.eUnit); else return (double)sStyleValue.nValue; break; default: bValueIsNull = TRUE; return 0; break; }}/****************************************************************************//* void OGRStyleTool::SetParamStr(OGRStyleParamId &sStyleParam , *//* OGRStyleValue &sStyleValue, *//* const char *pszParamString) *//* *//****************************************************************************/void OGRStyleTool::SetParamStr(OGRStyleParamId &sStyleParam , OGRStyleValue &sStyleValue, const char *pszParamString){ Parse(); StyleModified(); sStyleValue.bValid = TRUE; sStyleValue.eUnit = GetUnit(); switch (sStyleParam.eType) { // if sStyleParam.bGeoref == TRUE , need to convert to output value; case OGRSTypeString: sStyleValue.pszValue = CPLStrdup(pszParamString); break; case OGRSTypeDouble: sStyleValue.dfValue = atof(pszParamString); break; case OGRSTypeInteger: sStyleValue.nValue = atoi(pszParamString); break; default: sStyleValue.bValid = FALSE; break; }}/****************************************************************************//* void OGRStyleTool::SetParamNum(OGRStyleParamId &sStyleParam , *//* OGRStyleValue &sStyleValue, *//* int nParam) *//* *//****************************************************************************/void OGRStyleTool::SetParamNum(OGRStyleParamId &sStyleParam , OGRStyleValue &sStyleValue, int nParam){ Parse(); StyleModified(); sStyleValue.bValid = TRUE; sStyleValue.eUnit = GetUnit(); switch (sStyleParam.eType) { // if sStyleParam.bGeoref == TRUE , need to convert to output value; case OGRSTypeString: sStyleValue.pszValue = CPLStrdup(CPLSPrintf("%d",nParam)); break; case OGRSTypeDouble: sStyleValue.dfValue = (double)nParam; break; case OGRSTypeInteger: sStyleValue.nValue = nParam; break; default: sStyleValue.bValid = FALSE; break; }}/****************************************************************************//* void OGRStyleTool::SetParamDbl(OGRStyleParamId &sStyleParam , *//* OGRStyleValue &sStyleValue, *//* double dfParam) *//* *//****************************************************************************/void OGRStyleTool::SetParamDbl(OGRStyleParamId &sStyleParam , OGRStyleValue &sStyleValue, double dfParam){ Parse(); StyleModified(); sStyleValue.bValid = TRUE; sStyleValue.eUnit = GetUnit(); switch (sStyleParam.eType) { // if sStyleParam.bGeoref == TRUE , need to convert to output value; case OGRSTypeString: sStyleValue.pszValue = CPLStrdup(CPLSPrintf("%f",dfParam)); break; case OGRSTypeDouble: sStyleValue.dfValue = dfParam; break; case OGRSTypeInteger: sStyleValue.nValue = (int)dfParam; break; default: sStyleValue.bValid = FALSE; break; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?