aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conversions/unitconvert.cpp19
-rw-r--r--src/proj.h4
2 files changed, 12 insertions, 11 deletions
diff --git a/src/conversions/unitconvert.cpp b/src/conversions/unitconvert.cpp
index d584d93f..991eb2e0 100644
--- a/src/conversions/unitconvert.cpp
+++ b/src/conversions/unitconvert.cpp
@@ -252,21 +252,22 @@ static double yyyymmdd_to_mjd(double yyyymmdd) {
/***********************************************************************/
static double mjd_to_yyyymmdd(double mjd) {
/************************************************************************
- Date given in YYYY-MM-DD format.
+ Date returned in YYYY-MM-DD format.
************************************************************************/
- double mjd_iter = 14 + 31;
- int year = 1859, month=0, day=0;
+ unsigned int date_iter = 14 + 31;
+ unsigned int year = 1859, month = 0, day = 0;
+ unsigned int date = (int) lround(mjd);
- for (; mjd >= mjd_iter; year++) {
- mjd_iter += days_in_year(year);
+ for (; date >= date_iter; year++) {
+ date_iter += days_in_year(year);
}
year--;
- mjd_iter -= days_in_year(year);
+ date_iter -= days_in_year(year);
- for (month=1; mjd_iter + days_in_month(year, month) <= mjd; month++)
- mjd_iter += days_in_month(year, month);
+ for (month=1; date_iter + days_in_month(year, month) <= date; month++)
+ date_iter += days_in_month(year, month);
- day = (int)(mjd - mjd_iter + 1);
+ day = date - date_iter + 1;
return year*10000.0 + month*100.0 + day;
}
diff --git a/src/proj.h b/src/proj.h
index 81dabaf8..06762898 100644
--- a/src/proj.h
+++ b/src/proj.h
@@ -379,12 +379,12 @@ PJ_CONTEXT PROJ_DLL *proj_context_clone (PJ_CONTEXT *ctx);
/** Callback to resolve a filename to a full path */
typedef const char* (*proj_file_finder) (PJ_CONTEXT *ctx, const char*, void* user_data);
+/*! @endcond */
void PROJ_DLL proj_context_set_file_finder(PJ_CONTEXT *ctx, proj_file_finder finder, void* user_data);
-/*! @endcond */
void PROJ_DLL proj_context_set_search_paths(PJ_CONTEXT *ctx, int count_paths, const char* const* paths);
-/*! @cond Doxygen_Suppress */
void PROJ_DLL proj_context_set_ca_bundle_path(PJ_CONTEXT *ctx, const char *path);
+/*! @cond Doxygen_Suppress */
void PROJ_DLL proj_context_use_proj4_init_rules(PJ_CONTEXT *ctx, int enable);
int PROJ_DLL proj_context_get_use_proj4_init_rules(PJ_CONTEXT *ctx, int from_legacy_code_path);