Permalink
Browse files

Beginners GDAL support, completely unfinished.

  • Loading branch information...
1 parent 1818fbf commit d0d5b3a255143a1c9074422447fb6000c948da98 @tmcw tmcw committed Feb 14, 2011
Showing with 26 additions and 1 deletion.
  1. +26 −1 mbutil.cpp
View
@@ -7,6 +7,9 @@
#include "include/sqlite3.h"
#include "include/sqlite_types.hpp"
+#include "gdal_priv.h"
+#include "cpl_conv.h" // for CPLMalloc()
+
void setup_mbtiles(std::string filename)
{
char* zErrMsg;
@@ -21,6 +24,23 @@ void setup_mbtiles(std::string filename)
NULL, 0, &zErrMsg);
}
+void raster_to_mbtiles(std::string input_filename, std::string output_filename)
+{
+ namespace fs = boost::filesystem;
+ if (!fs::is_regular_file(output_filename))
+ {
+ setup_mbtiles(output_filename);
+ }
+
+ GDALDataset *poDataset;
+ GDALAllRegister();
+ poDataset = (GDALDataset *) GDALOpen(input_filename.c_str(), GA_ReadOnly);
+ if(poDataset == NULL)
+ {
+ std::cerr << "GDAL input could not be opened\n";
+ }
+}
+
void disk_to_mbtiles(std::string input_filename, std::string output_filename)
{
namespace fs = boost::filesystem;
@@ -129,7 +149,12 @@ int main(int ac, char** av)
std::string input_filename = vm["input"].as<std::string>();
std::string output_filename = vm["output"].as<std::string>();
- if (fs::is_regular_file(input_filename))
+ if (fs::is_regular_file(input_filename) &&
+ fs::is_regular_file(output_filename))
+ {
+ raster_to_mbtiles(input_filename, output_filename);
+ }
+ else if (fs::is_regular_file(input_filename))
{
mbtiles_to_disk(input_filename, output_filename);
}

0 comments on commit d0d5b3a

Please sign in to comment.