From 6e98dd2875b3339cebc9faacfa8c6bb668b49f54 Mon Sep 17 00:00:00 2001
From: Alexander Herzig <herziga@landcareresearch.co.nz>
Date: Thu, 7 Feb 2013 09:36:56 +1300
Subject: [PATCH] provisional patch: adding tiling support to rasimport
---
applications/rasgeo/RasdamanHelper2.cxx | 9 ++++++++-
applications/rasgeo/RasdamanHelper2.h | 4 ++--
applications/rasgeo/rimport.cxx | 19 +++++++++++++------
applications/rasgeo/rimport.h | 4 ++--
4 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/applications/rasgeo/RasdamanHelper2.cxx b/applications/rasgeo/RasdamanHelper2.cxx
index 498fda9..5ec486b 100644
|
a
|
b
|
unsigned int RasdamanHelper2::getBaseTypeSize(std::string collname)
|
| 480 | 480 | |
| 481 | 481 | double RasdamanHelper2::insertImage(std::string collname, |
| 482 | 482 | char* buf, r_Point& shift, r_Minterval& sdom, bool bRowMajor2ColMajor, |
| 483 | | std::string marraytypename) |
| | 483 | std::string marraytypename, std::string tiling) |
| 484 | 484 | { |
| 485 | 485 | NMDebugCtx(ctxrhelper, << "..."); |
| 486 | 486 | |
| … |
… |
double RasdamanHelper2::insertImage(std::string collname,
|
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | |
| | 535 | // if the specified tiling string is not empty, we just append it to the insert query |
| | 536 | // string - we rely on r_oql to throw an execption, if anything is wrong ... |
| | 537 | if (!tiling.empty()) |
| | 538 | { |
| | 539 | qstr += " " + tiling; |
| | 540 | } |
| | 541 | |
| 535 | 542 | NMDebugAI( << "dummy grid query: " << qstr << std::endl); |
| 536 | 543 | |
| 537 | 544 | r_OQL_Query qins(qstr.c_str()); |
diff --git a/applications/rasgeo/RasdamanHelper2.h b/applications/rasgeo/RasdamanHelper2.h
index 049b81b..fde97cc 100644
|
a
|
b
|
public:
|
| 148 | 148 | /*! insert an image into the collection */ |
| 149 | 149 | double insertImage(std::string collname, char* buf, |
| 150 | 150 | r_Point& shift, r_Minterval& sdom, bool bRowMajor2ColMajor, |
| 151 | | std::string marraytypename = ""); |
| | 151 | std::string marraytypename, std::string tiling); |
| 152 | 152 | |
| 153 | 153 | /*! update an already present image in the collection */ |
| 154 | 154 | void updateImage(std::string collname, double imgid, |
| 155 | 155 | char* buf, r_Point& shift, r_Minterval& sdom, bool bRowMajor2ColMajor, |
| 156 | | std::string marraytypename = "") |
| | 156 | std::string marraytypename) |
| 157 | 157 | throw (r_Error); |
| 158 | 158 | |
| 159 | 159 | |
diff --git a/applications/rasgeo/rimport.cxx b/applications/rasgeo/rimport.cxx
index ab8661f..1d27aef 100644
|
a
|
b
|
int
|
| 461 | 461 | processImageFiles(vector<string>& filenames, string collname, |
| 462 | 462 | vector<double>& oids, Header& processRegion, |
| 463 | 463 | string mode3D, r_Point& shiftPt, RasdamanHelper2& helper, |
| 464 | | std::string marraytypename) |
| | 464 | std::string marraytypename, std::string tiling) |
| 465 | 465 | { |
| 466 | 466 | /* PROCEDURE |
| 467 | 467 | * - read source geospatial region (srcGeoRegion) |
| … |
… |
processImageFiles(vector<string>& filenames, string collname,
|
| 678 | 678 | printRegion(newGeoRegion, "newGeoRegion"); |
| 679 | 679 | |
| 680 | 680 | importImage(helper, pDs, collname, oids, readGDALImgDOM, writeShift, |
| 681 | | newGeoRegion, b3D, marraytypename); |
| | 681 | newGeoRegion, b3D, marraytypename, tiling); |
| 682 | 682 | |
| 683 | 683 | // release data set |
| 684 | 684 | GDALClose(pDs); |
| … |
… |
processImageFiles(vector<string>& filenames, string collname,
|
| 709 | 709 | |
| 710 | 710 | int importImage(RasdamanHelper2& helper, GDALDataset* pDs, string& collname, vector<double>& oids, |
| 711 | 711 | r_Minterval& readGDALImgDOM, r_Point& writeShift, Header& newGeoRegion, |
| 712 | | bool asCube, std::string marraytypename) |
| | 712 | bool asCube, std::string marraytypename, std::string tiling) |
| 713 | 713 | { |
| 714 | 714 | NMDebugCtx(ctxRimport, << "..."); |
| 715 | 715 | |
| … |
… |
int importImage(RasdamanHelper2& helper, GDALDataset* pDs, string& collname, vec
|
| 791 | 791 | |
| 792 | 792 | if (iter == 0 && oids.size() < b) |
| 793 | 793 | oids.push_back(helper.insertImage(collname, (char*)gdalbuf, seqWriteShift, rint, true, |
| 794 | | marraytypename)); |
| | 794 | marraytypename, tiling)); |
| 795 | 795 | else |
| 796 | 796 | helper.updateImage(collname, oids[b-1], (char*)gdalbuf, seqWriteShift, rint, true, |
| 797 | 797 | marraytypename); |
| … |
… |
int importImage(RasdamanHelper2& helper, GDALDataset* pDs, string& collname, vec
|
| 810 | 810 | if (iter == 0 && oids.size() == 0) |
| 811 | 811 | { |
| 812 | 812 | oids.push_back(helper.insertImage(collname, (char*)gdalbuf, seqWriteShift, rint, true, |
| 813 | | marraytypename)); |
| | 813 | marraytypename, tiling)); |
| 814 | 814 | } |
| 815 | 815 | else |
| 816 | 816 | { |
| … |
… |
main(int argc, char** argv)
|
| 1068 | 1068 | std::string collname; // -coll |
| 1069 | 1069 | std::string connfile; // -conn |
| 1070 | 1070 | std::string mode3D; // -3D |
| | 1071 | std::string tilingSpec; // -tiling |
| 1071 | 1072 | |
| 1072 | 1073 | double cellsizez = -1; // -csz |
| 1073 | 1074 | std::vector<double> bnd; // -bnd |
| … |
… |
main(int argc, char** argv)
|
| 1203 | 1204 | return EXIT_FAILURE; |
| 1204 | 1205 | } |
| 1205 | 1206 | } |
| | 1207 | else if (theArg == "-tiling") |
| | 1208 | { |
| | 1209 | tilingSpec = argv[arg+1]; |
| | 1210 | } |
| 1206 | 1211 | else if (theArg == "--help") |
| 1207 | 1212 | { |
| 1208 | 1213 | showHelp(); |
| … |
… |
main(int argc, char** argv)
|
| 1241 | 1246 | NMDebug(<< usertype.at(t) << " "); |
| 1242 | 1247 | NMDebug(<< std::endl); |
| 1243 | 1248 | |
| | 1249 | NMDebugInd(1, << "tiling scheme: " << tilingSpec << std::endl); |
| | 1250 | |
| 1244 | 1251 | // ----------------------------------------------------------------------- |
| 1245 | 1252 | // EVALUATE ARGUMENTS |
| 1246 | 1253 | // get the connection file and check readability |
| … |
… |
main(int argc, char** argv)
|
| 1353 | 1360 | marraytypename = usertype.at(0); |
| 1354 | 1361 | |
| 1355 | 1362 | if (!processImageFiles(vimportnames, collname, oids, header, mode3D, |
| 1356 | | shiftPt, helper, marraytypename)) |
| | 1363 | shiftPt, helper, marraytypename, tilingSpec)) |
| 1357 | 1364 | { |
| 1358 | 1365 | NMErr(ctxRimport, << "Failed processing image file(s)!"); |
| 1359 | 1366 | return EXIT_FAILURE; |
diff --git a/applications/rasgeo/rimport.h b/applications/rasgeo/rimport.h
index ecdb91b..0aace0e 100644
|
a
|
b
|
void showHelp();
|
| 133 | 133 | |
| 134 | 134 | int importImage(RasdamanHelper2& helper, GDALDataset* pDs, string& collname, vector<double>& oids, |
| 135 | 135 | r_Minterval& readGDALImgDOM, r_Point& writeShift, Header& newGeoRegion, |
| 136 | | bool asCube, std::string marraytypename = ""); |
| | 136 | bool asCube, std::string marraytypename, string tiling); |
| 137 | 137 | |
| 138 | 138 | int processImageFiles(vector<string>& filenames, string collname, vector<double>& oids, |
| 139 | 139 | Header& processRegion, string mode3D, r_Point& shiftPt, RasdamanHelper2& helper, |
| 140 | | std::string marraytypename = ""); |
| | 140 | std::string marraytypename, string tiling); |
| 141 | 141 | |
| 142 | 142 | void intersectRegions2D(Header& inoutRegion, Header& intersectRegion); |
| 143 | 143 | void intersectRegions2D(Header& inoutRegion, std::vector<double>& intersectRegions); |