Revision: 77068
http://sourceforge.net/p/brlcad/code/77068
Author: brlcad
Date: 2020-09-06 05:48:11 +0000 (Sun, 06 Sep 2020)
Log Message:
-----------
fit comments and separate if expression from the true block for consistent
readability
Modified Paths:
--------------
brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp
brlcad/trunk/src/libgcv/plugins/gdal/gdal_ll.cpp
Modified: brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp
===================================================================
--- brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp 2020-09-04 21:05:55 UTC
(rev 77067)
+++ brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp 2020-09-06 05:48:11 UTC
(rev 77068)
@@ -97,7 +97,8 @@
get_dataset_info(GDALDatasetH hDataset)
{
char *gdal_info = GDALInfo(hDataset, NULL);
- if (gdal_info) bu_log("%s", gdal_info);
+ if (gdal_info)
+ bu_log("%s", gdal_info);
CPLFree(gdal_info);
return 0;
}
@@ -108,13 +109,16 @@
GDALDatasetH hDataset;
GDALAllRegister();
- if (!data) return 0;
+ if (!data)
+ return 0;
- if (!bu_file_exists(data,NULL)) return 0;
+ if (!bu_file_exists(data,NULL))
+ return 0;
hDataset = GDALOpenEx(data, GDAL_OF_READONLY | GDAL_OF_RASTER , NULL,
NULL, NULL);
- if (!hDataset) return 0;
+ if (!hDataset)
+ return 0;
GDALClose(hDataset);
@@ -129,7 +133,8 @@
GDALRasterBandH band = GDALGetRasterBand(ds, 1);
mm[0] = GDALGetRasterMinimum(band, &bmin);
mm[1] = GDALGetRasterMaximum(band, &bmin);
- if (!bmin || !bmax) GDALComputeRasterMinMax(band, TRUE, mm);
+ if (!bmin || !bmax)
+ GDALComputeRasterMinMax(band, TRUE, mm);
bu_log("Elevation Minimum/Maximum: %f, %f\n", mm[0], mm[1]);
}
@@ -203,14 +208,17 @@
(void)get_dataset_info(state->hDataset);
gdal_elev_minmax(state->hDataset);
- /* Stash the original Spatial Reference System as a PROJ.4 string for
later assignment */
+ /* Stash the original Spatial Reference System as a PROJ.4 string
+ * for later assignment
+ */
char *orig_proj4_str = NULL;
OGRSpatialReference iSRS(GDALGetProjectionRef(state->hDataset));
iSRS.exportToProj4(&orig_proj4_str);
- /* Use the information in the data set to deduce the EPSG number
corresponding
- * to the correct UTM projection zone, define a spatial reference, and
generate
- * the "Well Known Text" to use as the argument to the warping function*/
+ /* Use the information in the data set to deduce the EPSG number
+ * corresponding to the correct UTM projection zone, define a
+ * spatial reference, and generate the "Well Known Text" to use as
+ * the argument to the warping function*/
GDALDatasetH hOutDS;
int zone = (state->ops->zone == INT_MAX) ? gdal_utm_zone(state) :
state->ops->zone;
char *dunit;
@@ -224,8 +232,8 @@
char *dst_Wkt = NULL;
oSRS.exportToWkt(&dst_Wkt);
- /* Perform the UTM data warp. At this point the data is not yet in the
- * form needed by the DSP primitive */
+ /* Perform the UTM data warp. At this point the data is not
+ * yet in the form needed by the DSP primitive */
hOutDS = GDALAutoCreateWarpedVRT(state->hDataset, NULL, dst_Wkt,
GRA_CubicSpline, 0.0, NULL);
CPLFree(dst_Wkt);
dunit = bu_strdup(GDALGetRasterUnitType(((GDALDataset
*)hOutDS)->GetRasterBand(1)));
@@ -236,10 +244,11 @@
hOutDS = state->hDataset;
dunit = bu_strdup(GDALGetRasterUnitType(((GDALDataset
*)hOutDS)->GetRasterBand(1)));
}
- if (!dunit || strlen(dunit) == 0) dunit = (char *)dunit_default;
+ if (!dunit || strlen(dunit) == 0)
+ dunit = (char *)dunit_default;
- /* Do the translate step (a.l.a gdal_translate) that puts the data in a
- * form we can use */
+ /* Do the translate step (a.l.a gdal_translate) that puts the data
+ * in a form we can use */
char *img_opts[3];
img_opts[0] = bu_strdup("-of");
img_opts[1] = bu_strdup("MEM");
@@ -247,12 +256,15 @@
GDALTranslateOptions *gdalt_opts = GDALTranslateOptionsNew(img_opts, NULL);
GDALDatasetH flatDS = GDALTranslate("", hOutDS, gdalt_opts, NULL);
GDALTranslateOptionsFree(gdalt_opts);
- if (hOutDS != state->hDataset) GDALClose(hOutDS);
+ if (hOutDS != state->hDataset)
+ GDALClose(hOutDS);
for(int i = 0; i < 3; i++) {
- if(img_opts[i]) bu_free(img_opts[i], "imgopt");
+ if(img_opts[i])
+ bu_free(img_opts[i], "imgopt");
}
- /* Stash the flat Spatial Reference System as a PROJ.4 string for later
assignment */
+ /* Stash the flat Spatial Reference System as a PROJ.4 string for
+ * later assignment */
char *flat_proj4_str = NULL;
OGRSpatialReference fSRS(GDALGetProjectionRef(flatDS));
fSRS.exportToProj4(&flat_proj4_str);
@@ -278,7 +290,8 @@
}
}
- /* Convert the data before writing it so the DSP get_obj_data routine sees
what it expects */
+ /* Convert the data before writing it so the DSP get_obj_data
+ * routine sees what it expects */
int in_cookie = bu_cv_cookie("hus");
int out_cookie = bu_cv_cookie("nus"); /* data is network unsigned short */
if (bu_cv_optimize(in_cookie) != bu_cv_optimize(out_cookie)) {
@@ -316,10 +329,11 @@
GDALClose(flatDS);
GDALClose(state->hDataset);
- /* TODO: if we're going to BoT (3-space mesh, will depend on the transform
requested) we will need different logic... */
+ /* TODO: if we're going to BoT (3-space mesh, will depend on the
+ * transform requested) we will need different logic... */
- /* Write out the dsp. Since we're using a data object, instead of a file,
- * do the setup by hand. */
+ /* Write out the dsp. Since we're using a data object, instead of
+ * a file, do the setup by hand. */
struct rt_dsp_internal *dsp;
BU_ALLOC(dsp, struct rt_dsp_internal);
dsp->magic = RT_DSP_INTERNAL_MAGIC;
@@ -346,8 +360,8 @@
wdb_export(state->wdbp, bu_vls_addr(&name_dsp), (void *)dsp, ID_DSP, 1);
- /* Write out the original and current Spatial Reference Systems and other
dimensional
- * information to attributes on the dsp */
+ /* Write out the original and current Spatial Reference Systems
+ * and other dimensional information to attributes on the dsp */
struct bu_attribute_value_set avs;
bu_avs_init_empty(&avs);
struct directory *dp = db_lookup(state->wdbp->dbip,
bu_vls_addr(&name_dsp), LOOKUP_QUIET);
@@ -370,9 +384,12 @@
(void)db5_update_attributes(dp, &avs, state->wdbp->dbip);
}
- if (dunit != dunit_default) bu_free(dunit, "free dunit");
- if (orig_proj4_str) CPLFree(orig_proj4_str);
- if (flat_proj4_str) CPLFree(flat_proj4_str);
+ if (dunit != dunit_default)
+ bu_free(dunit, "free dunit");
+ if (orig_proj4_str)
+ CPLFree(orig_proj4_str);
+ if (flat_proj4_str)
+ CPLFree(flat_proj4_str);
bu_vls_free(&new_proj4_str);
bu_vls_free(&name_root);
Modified: brlcad/trunk/src/libgcv/plugins/gdal/gdal_ll.cpp
===================================================================
--- brlcad/trunk/src/libgcv/plugins/gdal/gdal_ll.cpp 2020-09-04 21:05:55 UTC
(rev 77067)
+++ brlcad/trunk/src/libgcv/plugins/gdal/gdal_ll.cpp 2020-09-06 05:48:11 UTC
(rev 77068)
@@ -66,19 +66,24 @@
CPLPopErrorHandler();
OSRDestroySpatialReference(hll);
}
- if(hpj != NULL) OSRDestroySpatialReference(hpj);
+ if (hpj != NULL)
+ OSRDestroySpatialReference(hpj);
}
if(htfm != NULL) {
if (OCTTransform(htfm,1,&longitude,&latitude,NULL)) {
- if (lat_center) (*lat_center) = latitude;
- if (long_center) (*long_center) = longitude;
+ if (lat_center)
+ *lat_center = latitude;
+ if (long_center)
+ *long_center = longitude;
} else {
return 0;
}
} else {
- if (lat_center) (*lat_center) = latitude;
- if (long_center) (*long_center) = longitude;
+ if (lat_center)
+ *lat_center = latitude;
+ if (long_center)
+ *long_center = longitude;
}
bu_log("lat: %f, long: %f\n", latitude, longitude);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits