MCPcopy Create free account
hub / github.com/OSGeo/gdal / GetField

Method GetField

apps/gdalalg_vector_make_point.cpp:108–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106 }
107
108 double GetField(const OGRFeature &feature, int fieldIndex, bool isString)
109 {
110 if (isString)
111 {
112 const char *pszValue = feature.GetFieldAsString(fieldIndex);
113 while (std::isspace(static_cast<unsigned char>(*pszValue)))
114 {
115 pszValue++;
116 }
117 char *end = nullptr;
118 double dfValue = CPLStrtodM(pszValue, &end);
119 while (std::isspace(static_cast<unsigned char>(*end)))
120 {
121 end++;
122 }
123 if (end == pszValue || *end != '\0')
124 {
125 const char *pszFieldName =
126 m_defn->GetFieldDefn(fieldIndex)->GetNameRef();
127 CPLError(CE_Failure, CPLE_AppDefined,
128 "Invalid value in field %s: %s ", pszFieldName,
129 pszValue);
130 FailTranslation();
131 }
132 return dfValue;
133 }
134 else
135 {
136 return feature.GetFieldAsDouble(fieldIndex);
137 }
138 }
139
140 bool CheckField(const std::string &dim, const std::string &fieldName,
141 int index, bool &isStringVar)

Calls 5

CPLStrtodMFunction · 0.85
CPLErrorFunction · 0.85
GetFieldAsStringMethod · 0.45
GetFieldDefnMethod · 0.45
GetFieldAsDoubleMethod · 0.45