diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-11-30 02:36:00 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-11-30 02:43:57 +0100 |
| commit | 664bd689bf8dd3ca38a5071459902b89114e88eb (patch) | |
| tree | 88db8dd01621321635c2ea4bc8782dbdc9305e14 /src/cs2cs.cpp | |
| parent | 28d69400b04eb683bfccb3e7d3ad8a054ad73897 (diff) | |
| download | PROJ-664bd689bf8dd3ca38a5071459902b89114e88eb.tar.gz PROJ-664bd689bf8dd3ca38a5071459902b89114e88eb.zip | |
C API: do not 'cache' PROJ context in PJ_OBJ objects
We store the PJ_CONTEXT* in the PJ_OBJ objects, but this
might cause issues in multi-threaded uses.
For example, before this change, let's imagie:
- a PJ_OBJ is created in thread A with a PJ_CONTEXT that
is specific to this thread A
- PJ_OBJ is transfered to another thread that operates on
it. It might thus use the PJ_CONTEXT that was TLS(A)
- in the meantime thread A does completely different things,
but still operate on its PJ_CONTEXT. We might get a
concurrent use of the PJ_CONTEXT despite working on
different PJ_OBJ
Another situation is when using constructor functions that
take two PJ_OBJ. Up to now, we arbitrarily selected the context
of one of the arguments to attach it to the new object.
So better be explicit on which context is used.
For reference, in those wrappers of the C++ API, the
context is mostly used for two things:
- reporting C++ exceptions as PROJ errors with the error handler
attached to the PJ_CONTEXT
- using the database handle that is associated with the PJ_CONTEXT.
Diffstat (limited to 'src/cs2cs.cpp')
| -rw-r--r-- | src/cs2cs.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cs2cs.cpp b/src/cs2cs.cpp index 8dc23ac5..a8d126cf 100644 --- a/src/cs2cs.cpp +++ b/src/cs2cs.cpp @@ -225,19 +225,19 @@ static PJ_OBJ *instanciate_crs(const std::string &definition, auto type = proj_obj_get_type(crs); if (type == PJ_OBJ_TYPE_BOUND_CRS) { - auto base = proj_obj_get_source_crs(crs); + auto base = proj_obj_get_source_crs(nullptr, crs); proj_obj_unref(crs); crs = base; type = proj_obj_get_type(crs); } if (type == PJ_OBJ_TYPE_GEOGRAPHIC_2D_CRS || type == PJ_OBJ_TYPE_GEOGRAPHIC_3D_CRS) { - auto cs = proj_obj_crs_get_coordinate_system(crs); + auto cs = proj_obj_crs_get_coordinate_system(nullptr, crs); assert(cs); isGeog = true; const char *axisName = ""; - proj_obj_cs_get_axis_info(cs, 0, + proj_obj_cs_get_axis_info(nullptr, cs, 0, &axisName, // name, nullptr, // abbrev nullptr, // direction @@ -263,7 +263,7 @@ static std::string get_geog_crs_proj_string_from_proj_crs(PJ_OBJ *src, bool &isLatFirst) { auto srcType = proj_obj_get_type(src); if (srcType == PJ_OBJ_TYPE_BOUND_CRS) { - auto base = proj_obj_get_source_crs(src); + auto base = proj_obj_get_source_crs(nullptr, src); assert(base); proj_obj_unref(src); src = base; @@ -273,7 +273,7 @@ static std::string get_geog_crs_proj_string_from_proj_crs(PJ_OBJ *src, return std::string(); } - auto base = proj_obj_get_source_crs(src); + auto base = proj_obj_get_source_crs(nullptr, src); assert(base); auto baseType = proj_obj_get_type(base); if (baseType != PJ_OBJ_TYPE_GEOGRAPHIC_2D_CRS && @@ -282,11 +282,11 @@ static std::string get_geog_crs_proj_string_from_proj_crs(PJ_OBJ *src, return std::string(); } - auto cs = proj_obj_crs_get_coordinate_system(base); + auto cs = proj_obj_crs_get_coordinate_system(nullptr, base); assert(cs); const char *axisName = ""; - proj_obj_cs_get_axis_info(cs, 0, + proj_obj_cs_get_axis_info(nullptr, cs, 0, &axisName, // name, nullptr, // abbrev nullptr, // direction @@ -298,7 +298,7 @@ static std::string get_geog_crs_proj_string_from_proj_crs(PJ_OBJ *src, proj_obj_unref(cs); - auto retCStr = proj_obj_as_proj_string(base, PJ_PROJ_5, nullptr); + auto retCStr = proj_obj_as_proj_string(nullptr, base, PJ_PROJ_5, nullptr); std::string ret(retCStr ? retCStr : ""); proj_obj_unref(base); return ret; |
