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

Function pj_datum_set

ThirdParty/libproj/vtklibproj/src/datum_set.cpp:40–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38/************************************************************************/
39
40int pj_datum_set(PJ_CONTEXT *ctx, paralist *pl, PJ *projdef)
41
42{
43 const char *name, *towgs84, *nadgrids;
44
45 projdef->datum_type = PJD_UNKNOWN;
46
47/* -------------------------------------------------------------------- */
48/* Is there a datum definition in the parameters list? If so, */
49/* add the defining values to the parameter list. Note that */
50/* this will append the ellipse definition as well as the */
51/* towgs84= and related parameters. It should also be pointed */
52/* out that the addition is permanent rather than temporary */
53/* like most other keyword expansion so that the ellipse */
54/* definition will last into the pj_ell_set() function called */
55/* after this one. */
56/* -------------------------------------------------------------------- */
57 if( (name = pj_param(ctx, pl,"sdatum").s) != nullptr )
58 {
59 paralist *curr;
60 const char *s;
61 int i;
62
63 /* find the end of the list, so we can add to it */
64 for (curr = pl; curr && curr->next ; curr = curr->next) {}
65
66 /* cannot happen in practice, but makes static analyzers happy */
67 if( !curr ) return -1;
68
69 /* find the datum definition */
70 for (i = 0; (s = pj_datums[i].id) && strcmp(name, s) ; ++i) {}
71
72 if (!s) {
73 pj_log (ctx, PJ_LOG_ERROR, _("Unknown value for datum"));
74 proj_context_errno_set(ctx, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE);
75 return 1;
76 }
77
78 if( pj_datums[i].ellipse_id && strlen(pj_datums[i].ellipse_id) > 0 )
79 {
80 char entry[100];
81
82 strcpy( entry, "ellps=" );
83 strncpy( entry + strlen(entry), pj_datums[i].ellipse_id,
84 sizeof(entry) - 1 - strlen(entry) );
85 entry[ sizeof(entry) - 1 ] = '\0';
86
87 auto param = pj_mkparam(entry);
88 if (nullptr == param)
89 {
90 proj_context_errno_set(ctx, PROJ_ERR_OTHER /*ENOMEM*/);
91 return 1;
92 }
93 curr->next = param;
94 curr = param;
95 }
96
97 if( pj_datums[i].defn && strlen(pj_datums[i].defn) > 0 )

Callers 1

Calls 5

pj_paramFunction · 0.85
pj_logFunction · 0.85
proj_context_errno_setFunction · 0.85
pj_mkparamFunction · 0.85
pj_atofFunction · 0.85

Tested by

no test coverage detected