MCPcopy Create free account
hub / github.com/Kitware/VTK / createFromUserInput

Function createFromUserInput

ThirdParty/libproj/vtklibproj/src/iso19111/io.cpp:6317–6853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6315// ---------------------------------------------------------------------------
6316
6317static BaseObjectNNPtr createFromUserInput(const std::string &text,
6318 const DatabaseContextPtr &dbContext,
6319 bool usePROJ4InitRules,
6320 PJ_CONTEXT *ctx) {
6321 std::size_t idxFirstCharNotSpace = text.find_first_not_of(" \t\r\n");
6322 if (idxFirstCharNotSpace > 0 && idxFirstCharNotSpace != std::string::npos) {
6323 return createFromUserInput(text.substr(idxFirstCharNotSpace), dbContext,
6324 usePROJ4InitRules, ctx);
6325 }
6326
6327 if (!text.empty() && text[0] == '{') {
6328 json j;
6329 try {
6330 j = json::parse(text);
6331 } catch (const std::exception &e) {
6332 throw ParsingException(e.what());
6333 }
6334 return JSONParser().attachDatabaseContext(dbContext).create(j);
6335 }
6336
6337 if (!ci_starts_with(text, "step proj=") &&
6338 !ci_starts_with(text, "step +proj=")) {
6339 for (const auto &wktConstant : WKTConstants::constants()) {
6340 if (ci_starts_with(text, wktConstant)) {
6341 for (auto wkt = text.c_str() + wktConstant.size(); *wkt != '\0';
6342 ++wkt) {
6343 if (isspace(static_cast<unsigned char>(*wkt)))
6344 continue;
6345 if (*wkt == '[') {
6346 return WKTParser()
6347 .attachDatabaseContext(dbContext)
6348 .setStrict(false)
6349 .createFromWKT(text);
6350 }
6351 break;
6352 }
6353 }
6354 }
6355 }
6356
6357 const char *textWithoutPlusPrefix = text.c_str();
6358 if (textWithoutPlusPrefix[0] == '+')
6359 textWithoutPlusPrefix++;
6360
6361 if (strncmp(textWithoutPlusPrefix, "proj=", strlen("proj=")) == 0 ||
6362 text.find(" +proj=") != std::string::npos ||
6363 text.find(" proj=") != std::string::npos ||
6364 strncmp(textWithoutPlusPrefix, "init=", strlen("init=")) == 0 ||
6365 text.find(" +init=") != std::string::npos ||
6366 text.find(" init=") != std::string::npos ||
6367 strncmp(textWithoutPlusPrefix, "title=", strlen("title=")) == 0) {
6368 return PROJStringParser()
6369 .attachDatabaseContext(dbContext)
6370 .attachContext(ctx)
6371 .setUsePROJ4InitRules(ctx != nullptr
6372 ? (proj_context_get_use_proj4_init_rules(
6373 ctx, false) == TRUE)
6374 : usePROJ4InitRules)

Callers 4

createGeodeticCRSMethod · 0.85
createProjectedCRSEndMethod · 0.85
proj_createFunction · 0.85
createFromPROJStringMethod · 0.85

Calls 15

JSONParserClass · 0.85
ci_starts_withFunction · 0.85
isCRSURLFunction · 0.85
importFromCRSURLFunction · 0.85
importFromWMSAUTOFunction · 0.85
createFunction · 0.85
ci_equalFunction · 0.85
PropertyMapClass · 0.85
ends_withFunction · 0.85
tolowerFunction · 0.85
replaceAllFunction · 0.85

Tested by

no test coverage detected