121155 {
121156 const auto node = WKTParser::Parse(text);
121157
121158 if (!node) {
121159
121160 return false;
121161 }
121162
121163 if (!node->IsKeyword()) {
121164 return false;
121165 }
121166
121167 const auto &keyword = node->As<WKTKeyword>();
121168
121169
121170 auto found = false;
121171
121172 const auto crs_keywords = {
121173
121174 "BOUNDCRS", "COMPOUNDCRS", "ENGCRS", "ENGINEERINGCRS", "GEODCRS",
121175 "GEODETICCRS", "GEOGCRS", "GEOGRAPHICCRS", "PARAMETRICCRS", "PROJCRS",
121176 "PROJECTEDCRS", "TIMECRS", "VERTCRS", "VERTICALCRS"
121177
121178
121179
121180
121181
121182
121183
121184
121185 };
121186
121187
121188 for (auto &kw : crs_keywords) {
121189 if (keyword.Match(kw)) {
121190 found = true;
121191 break;
121192 }
121193 }
121194
121195 if (!found) {
121196
121197 return false;
121198 }
121199
121200 auto &children = keyword.GetChildren();
121201 if (children.empty()) {
121202
121203 return false;
121204 }
121205
121206
121207 if (keyword.Match("BOUNDCRS")) {
121208 if (children.size() < 3) {
121209
121210 return false;
121211 }
121212
121213 const auto &transform_node = children[2];
121214 if (!transform_node->IsKeyword()) {
121215
121216 return false;
121217 }
121218
121219 const auto &transform_keyword = transform_node->As<WKTKeyword>();
121220 auto &transform_children = transform_keyword.GetChildren();
121221 if (transform_children.empty()) {
121222
121223 return false;
121224 }
121225
121226 const auto &first_transform_child = transform_children[0];
121227 if (!first_transform_child->IsString()) {
121228
121229 return false;
121230 }
121231
121232
121233 auto name = TryExtractIDFromWKTNode(transform_keyword);
121234 if (name.empty()) {
121235
121236 name = first_transform_child->As<WKTString>().GetValue();
121237 }
121238
121240 result.identifier = name;
121241 result.definition = text;
121242
121243
121244
121246
121247 return true;
121248 }
121249
121250
121251 const auto &first = children[0];
121252 if (!first->IsString()) {
121253
121254 return false;
121255 }
121256
121257 auto name = TryExtractIDFromWKTNode(keyword);
121258 if (name.empty()) {
121259
121260 name = first->As<WKTString>().GetValue();
121261 }
121262
121264 result.identifier = name;
121265 result.definition = text;
121266
121267
121268
121270
121271 return true;
121272}
static DUCKDB_API void Trim(string &str)
Remove the whitespace char in the left and right end of the string.
Definition duckdb.cpp:109372