From c57e293fbf2b79a24519c70d558e1268515a9ee6 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 24 Nov 2018 11:01:11 +0100 Subject: Reformat test .cpp files --- scripts/reformat_cpp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/reformat_cpp.sh b/scripts/reformat_cpp.sh index 51127529..b50fa1e1 100755 --- a/scripts/reformat_cpp.sh +++ b/scripts/reformat_cpp.sh @@ -15,7 +15,7 @@ esac TOPDIR="$SCRIPT_DIR/.." -for i in "$TOPDIR"/include/proj/*.hpp "$TOPDIR"/include/proj/internal/*.hpp "$TOPDIR"/src/*.cpp "$TOPDIR"/test/unit/test*.cpp; do +for i in "$TOPDIR"/include/proj/*.hpp "$TOPDIR"/include/proj/internal/*.hpp "$TOPDIR"/src/*.cpp "$TOPDIR"/test/unit/*.cpp; do if ! echo "$i" | grep -q "lru_cache.hpp"; then "$SCRIPT_DIR"/reformat.sh "$i"; fi -- cgit v1.2.3 From 67758b2c67ea329116b59818c038797667c4e1d1 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 26 Nov 2018 15:47:57 +0100 Subject: Redirect epsg:XXXX and IGNF:XXXX CRS expansions to the database, and remove the data/epsg and data/IGNF files --- scripts/build_db_from_esri.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts') diff --git a/scripts/build_db_from_esri.py b/scripts/build_db_from_esri.py index f642b473..bea48925 100755 --- a/scripts/build_db_from_esri.py +++ b/scripts/build_db_from_esri.py @@ -54,6 +54,9 @@ all_sql = [] version = 'ArcMap 10.6.1 / ArcGISPro 2.2' all_sql.append( """INSERT INTO "metadata" VALUES('ESRI.VERSION', '%s');""" % (version)) +date = '2018-09-19' +all_sql.append( + """INSERT INTO "metadata" VALUES('ESRI.DATE', '%s');""" % (date)) def escape_literal(x): -- cgit v1.2.3 From cf855b24d2b901054bee90309cdc5df00dfb3085 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 28 Nov 2018 14:52:56 +0100 Subject: C API extensions and renaming - proj_obj_create_projected_XXXXX() are renamed to proj_obj_create_conversion_snake_case() and just instanciate a Conversion object - Advanced manipulation functions are moved to a dedicated section at bottom of proj.h - New C API needed for GDAL OGRSpatialReference --- scripts/create_c_api_projections.py | 55 +++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/create_c_api_projections.py b/scripts/create_c_api_projections.py index 5d10a16b..a56e99b3 100755 --- a/scripts/create_c_api_projections.py +++ b/scripts/create_c_api_projections.py @@ -56,6 +56,21 @@ cppfile.write("\n"); test_cppfile.write("/* BEGIN: Generated by scripts/create_c_api_projections.py*/\n") +def snake_casify(s): + out = '' + lastWasLowerAlpha = False + for c in s: + if c.isupper(): + if lastWasLowerAlpha: + out += '_' + out += c.lower() + lastWasLowerAlpha = False + else: + out += c + lastWasLowerAlpha = c.isalpha() + return out + + for sectiondef in compounddef.iter('sectiondef'): if sectiondef.attrib['kind'] == 'public-static-func': for func in sectiondef.iter('memberdef'): @@ -79,22 +94,31 @@ for sectiondef in compounddef.iter('sectiondef'): params.append((type, paramname)) shortName = name[len('create'):] + c_shortName = snake_casify(shortName) - decl = "proj_obj_create_projected_crs_" - decl += shortName + decl = "proj_obj_create_conversion_" + decl += c_shortName decl += "(\n" - decl += " PJ_OBJ* geodetic_crs, const char* crs_name,\n" + decl += " PJ_CONTEXT *ctx,\n" + has_output_params = False for param in params: + if has_output_params: + decl += ",\n" + if param[0] in ('int', 'bool'): - decl += " int " + param[1] + ",\n" + decl += " int " + param[1] else: - decl += " double " + param[1] + ",\n" + decl += " double " + param[1] + has_output_params = True + if has_angle: + if has_output_params: + decl += ",\n" decl += " const char* angUnitName, double angUnitConvFactor" - if has_linear: - decl += "," - decl += "\n" + has_output_params = True if has_linear: + if has_output_params: + decl += ",\n" decl += " const char* linearUnitName, double linearUnitConvFactor" decl += ")" @@ -113,9 +137,8 @@ for sectiondef in compounddef.iter('sectiondef'): cppfile.write(" * Angular parameters are expressed in (angUnitName, angUnitConvFactor).\n") cppfile.write(" */\n") cppfile.write("PJ_OBJ* " + decl + "{\n"); - if not has_linear: - cppfile.write(" const auto& linearUnit = UnitOfMeasure::METRE;\n") - else: + cppfile.write(" try {\n"); + if has_linear: cppfile.write(" UnitOfMeasure linearUnit(createLinearUnit(linearUnitName, linearUnitConvFactor));\n") if has_angle: cppfile.write(" UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));\n") @@ -133,12 +156,16 @@ for sectiondef in compounddef.iter('sectiondef'): cppfile.write(", Scale(" + param[1] + ")") cppfile.write(");\n") - cppfile.write(" return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv, linearUnit);\n") + cppfile.write(" return proj_obj_create_conversion(ctx, conv);\n") + cppfile.write(" } catch (const std::exception &e) {\n"); + cppfile.write(" proj_log_error(ctx, __FUNCTION__, e.what());\n") + cppfile.write(" }\n") + cppfile.write(" return nullptr;\n") cppfile.write("}\n") test_cppfile.write("{\n") - test_cppfile.write(" auto projCRS = proj_obj_create_projected_crs_" + shortName + "(\n") - test_cppfile.write(" geogCRS, nullptr") + test_cppfile.write(" auto projCRS = proj_obj_create_conversion_" + c_shortName + "(\n") + test_cppfile.write(" m_ctxt") for param in params: test_cppfile.write(", 0") if has_angle: -- cgit v1.2.3 From 664bd689bf8dd3ca38a5071459902b89114e88eb Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 30 Nov 2018 02:36:00 +0100 Subject: 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. --- scripts/create_c_api_projections.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/create_c_api_projections.py b/scripts/create_c_api_projections.py index a56e99b3..a551469d 100755 --- a/scripts/create_c_api_projections.py +++ b/scripts/create_c_api_projections.py @@ -137,6 +137,7 @@ for sectiondef in compounddef.iter('sectiondef'): cppfile.write(" * Angular parameters are expressed in (angUnitName, angUnitConvFactor).\n") cppfile.write(" */\n") cppfile.write("PJ_OBJ* " + decl + "{\n"); + cppfile.write(" SANITIZE_CTX(ctx);\n"); cppfile.write(" try {\n"); if has_linear: cppfile.write(" UnitOfMeasure linearUnit(createLinearUnit(linearUnitName, linearUnitConvFactor));\n") @@ -156,7 +157,7 @@ for sectiondef in compounddef.iter('sectiondef'): cppfile.write(", Scale(" + param[1] + ")") cppfile.write(");\n") - cppfile.write(" return proj_obj_create_conversion(ctx, conv);\n") + cppfile.write(" return proj_obj_create_conversion(conv);\n") cppfile.write(" } catch (const std::exception &e) {\n"); cppfile.write(" proj_log_error(ctx, __FUNCTION__, e.what());\n") cppfile.write(" }\n") -- cgit v1.2.3 From 2d1deb2da9eab38febb4d4ce92faffa5d25a1e58 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 30 Nov 2018 02:54:00 +0100 Subject: C API: more camel_casification of parameters --- scripts/create_c_api_projections.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/create_c_api_projections.py b/scripts/create_c_api_projections.py index a551469d..897212ee 100755 --- a/scripts/create_c_api_projections.py +++ b/scripts/create_c_api_projections.py @@ -91,7 +91,7 @@ for sectiondef in compounddef.iter('sectiondef'): paramname = param.find('declname').text if paramname == 'properties': continue - params.append((type, paramname)) + params.append((type, snake_casify(paramname))) shortName = name[len('create'):] c_shortName = snake_casify(shortName) @@ -114,12 +114,12 @@ for sectiondef in compounddef.iter('sectiondef'): if has_angle: if has_output_params: decl += ",\n" - decl += " const char* angUnitName, double angUnitConvFactor" + decl += " const char* ang_unit_name, double ang_unit_conv_factor" has_output_params = True if has_linear: if has_output_params: decl += ",\n" - decl += " const char* linearUnitName, double linearUnitConvFactor" + decl += " const char* linear_unit_name, double linear_unit_conv_factor" decl += ")" header.write("PJ_OBJ PROJ_DLL *" + decl + ";\n\n") @@ -132,17 +132,17 @@ for sectiondef in compounddef.iter('sectiondef'): cppfile.write(" *\n") cppfile.write(" * See osgeo::proj::operation::Conversion::create" + shortName + "().\n") cppfile.write(" *\n") - cppfile.write(" * Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).\n") + cppfile.write(" * Linear parameters are expressed in (linear_unit_name, linear_unit_conv_factor).\n") if has_angle: - cppfile.write(" * Angular parameters are expressed in (angUnitName, angUnitConvFactor).\n") + cppfile.write(" * Angular parameters are expressed in (ang_unit_name, ang_unit_conv_factor).\n") cppfile.write(" */\n") cppfile.write("PJ_OBJ* " + decl + "{\n"); cppfile.write(" SANITIZE_CTX(ctx);\n"); cppfile.write(" try {\n"); if has_linear: - cppfile.write(" UnitOfMeasure linearUnit(createLinearUnit(linearUnitName, linearUnitConvFactor));\n") + cppfile.write(" UnitOfMeasure linearUnit(createLinearUnit(linear_unit_name, linear_unit_conv_factor));\n") if has_angle: - cppfile.write(" UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));\n") + cppfile.write(" UnitOfMeasure angUnit(createAngularUnit(ang_unit_name, ang_unit_conv_factor));\n") cppfile.write(" auto conv = Conversion::create" + shortName + "(PropertyMap()") for param in params: if param[0] in 'int': -- cgit v1.2.3