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

Function proj_get_id_code

src/iso19111/c_api.cpp:1591–1604  ·  view source on GitHub ↗

\brief Get the code of an identifier of an object. * * The lifetime of the returned string is the same as the input obj parameter. * * @param obj Object (must not be NULL) * @param index Index of the identifier. 0 = first identifier * @return a string, or NULL in case of error or missing name. */

Source from the content-addressed store, hash-verified

1589 * @return a string, or NULL in case of error or missing name.
1590 */
1591const char *proj_get_id_code(const PJ *obj, int index) {
1592 if (!obj) {
1593 return nullptr;
1594 }
1595 auto identifiedObj = dynamic_cast<IdentifiedObject *>(obj->iso_obj.get());
1596 if (!identifiedObj) {
1597 return nullptr;
1598 }
1599 const auto &ids = identifiedObj->identifiers();
1600 if (static_cast<size_t>(index) >= ids.size()) {
1601 return nullptr;
1602 }
1603 return ids[index]->code().c_str();
1604}
1605
1606// ---------------------------------------------------------------------------
1607

Callers 2

TEST_FFunction · 0.85
mainFunction · 0.85

Calls 2

sizeMethod · 0.80
getMethod · 0.45

Tested by 1

TEST_FFunction · 0.68