MCPcopy Create free account
hub / github.com/OSGeo/PROJ / get_init

Function get_init

src/init.cpp:212–317  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

210
211/************************************************************************/
212static paralist *get_init(PJ_CONTEXT *ctx, const char *key,
213 int allow_init_epsg) {
214 /*************************************************************************
215 Expand key from buffer or (if not in buffer) from init file
216 *************************************************************************/
217 const char *xkey;
218 char *definition = nullptr;
219 paralist *init_items = nullptr;
220
221 if (!ctx) {
222 ctx = pj_get_default_ctx();
223 }
224
225 /* support "init=file:section", "+init=file:section", and "file:section"
226 * 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;

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