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

Function pj_obj_create

ThirdParty/libproj/vtklibproj/src/iso19111/c_api.cpp:190–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188// ---------------------------------------------------------------------------
189
190static PJ *pj_obj_create(PJ_CONTEXT *ctx, const IdentifiedObjectNNPtr &objIn) {
191 auto coordop = dynamic_cast<const CoordinateOperation *>(objIn.get());
192 if (coordop) {
193 auto dbContext = getDBcontextNoException(ctx, __FUNCTION__);
194 try {
195 auto formatter = PROJStringFormatter::create(
196 PROJStringFormatter::Convention::PROJ_5, dbContext);
197 auto projString = coordop->exportToPROJString(formatter.get());
198 if (proj_context_is_network_enabled(ctx)) {
199 ctx->defer_grid_opening = true;
200 }
201 auto pj = pj_create_internal(ctx, projString.c_str());
202 ctx->defer_grid_opening = false;
203 if (pj) {
204 pj->iso_obj = objIn;
205 return pj;
206 }
207 } catch (const std::exception &) {
208 // Silence, since we may not always be able to export as a
209 // PROJ string.
210 }
211 }
212 auto pj = pj_new();
213 if (pj) {
214 pj->ctx = ctx;
215 pj->descr = "ISO-19111 object";
216 pj->iso_obj = objIn;
217 try {
218 auto crs = dynamic_cast<const CRS *>(objIn.get());
219 if (crs) {
220 auto geodCRS = crs->extractGeodeticCRS();
221 if (geodCRS) {
222 const auto &ellps = geodCRS->ellipsoid();
223 const double a = ellps->semiMajorAxis().getSIValue();
224 const double es = ellps->squaredEccentricity();
225 pj_calc_ellipsoid_params(pj, a, es);
226 assert(pj->geod == nullptr);
227 pj->geod = static_cast<struct geod_geodesic *>(
228 calloc(1, sizeof(struct geod_geodesic)));
229 if (pj->geod) {
230 geod_init(pj->geod, pj->a,
231 pj->es / (1 + sqrt(pj->one_es)));
232 }
233 }
234 }
235 } catch (const std::exception &) {
236 }
237 }
238 return pj;
239}
240//! @endcond
241
242// ---------------------------------------------------------------------------

Callers 15

proj_cloneFunction · 0.85
proj_createFunction · 0.85
proj_create_from_wktFunction · 0.85
proj_crs_get_sub_crsFunction · 0.85
proj_get_ellipsoidFunction · 0.85
proj_get_prime_meridianFunction · 0.85

Calls 14

createFunction · 0.85
pj_create_internalFunction · 0.85
pj_newFunction · 0.85
pj_calc_ellipsoid_paramsFunction · 0.85
geod_initFunction · 0.85
extractGeodeticCRSMethod · 0.80
getSIValueMethod · 0.80
squaredEccentricityMethod · 0.80
assertFunction · 0.50
sqrtFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected