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

Function get_init

ThirdParty/libproj/vtklibproj/src/init.cpp:214–318  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

212
213/************************************************************************/
214static paralist *get_init(PJ_CONTEXT *ctx, const char *key, int allow_init_epsg) {
215/*************************************************************************
216Expand key from buffer or (if not in buffer) from init file
217*************************************************************************/
218 const char *xkey;
219 char *definition = nullptr;
220 paralist *init_items = nullptr;
221
222 if( !ctx ) {
223 ctx = pj_get_default_ctx();
224 }
225
226 /* support "init=file:section", "+init=file:section", and "file:section" format */
227 xkey = strstr (key, "init=");
228 if (nullptr==xkey)
229 xkey = key;
230 else
231 xkey += 5;
232 pj_log (ctx, PJ_LOG_TRACE, "get_init: searching cache for key: [%s]", xkey);
233
234 /* Is file/key pair already in cache? */
235 init_items = pj_search_initcache (xkey);
236 if (init_items)
237 return init_items;
238
239 if( (strncmp(xkey, "epsg:", 5) == 0 || strncmp(xkey, "IGNF:", 5) == 0) ) {
240 char unused[256];
241 char initname[5];
242 int exists;
243
244 strncpy(initname, xkey, 4);
245 initname[4] = 0;
246
247 if( strncmp(xkey, "epsg:", 5) == 0 ) {
248 exists = ctx->epsg_file_exists;
249 if( exists < 0 ) {
250 exists = pj_find_file(ctx, initname, unused, sizeof(unused));
251 ctx->epsg_file_exists = exists;
252 }
253 } else {
254 exists = pj_find_file(ctx, initname, unused, sizeof(unused));
255 }
256
257 if( !exists ) {
258 char szInitStr[7 + 64];
259 PJ* src;
260 const char* proj_string;
261
262 proj_context_errno_set( ctx, 0 );
263
264 if( !allow_init_epsg ) {
265 pj_log (ctx, PJ_LOG_TRACE, "%s expansion disallowed", xkey);
266 return nullptr;
267 }
268 if( strlen(xkey) > 64 ) {
269 return nullptr;
270 }
271 strcpy(szInitStr, "+init=");

Callers 1

pj_expand_init_internalFunction · 0.85

Calls 11

pj_get_default_ctxFunction · 0.85
pj_logFunction · 0.85
pj_search_initcacheFunction · 0.85
pj_find_fileFunction · 0.85
proj_context_errno_setFunction · 0.85
proj_createFunction · 0.85
proj_as_proj_stringFunction · 0.85
proj_destroyFunction · 0.85
get_init_stringFunction · 0.85
string_to_paralistFunction · 0.85
pj_insert_initcacheFunction · 0.85

Tested by

no test coverage detected