Add a flag to never output empty images.

This commit is contained in:
Martijn Versteegh 2018-10-31 16:18:29 +01:00
parent 05f2b7f1a8
commit 1c203eb7bd
5 changed files with 26 additions and 0 deletions

View File

@ -83,6 +83,9 @@ extent:
noshading:
Don't draw shading on nodes, ``--noshading``
noemptyimage:
Don't output anything when the image would be empty, ``--noemptyimage``
min-y:
Don't draw nodes below this y value, e.g. ``--min-y -25``

View File

@ -79,6 +79,7 @@ TileGenerator::TileGenerator():
m_drawScale(false),
m_drawAlpha(false),
m_shading(true),
m_dontWriteEmpty(false),
m_backend(""),
m_xBorder(0),
m_yBorder(0),
@ -228,6 +229,10 @@ void TileGenerator::printGeometry(const std::string &input)
}
void TileGenerator::setDontWriteEmpty(bool f)
{
m_dontWriteEmpty = f;
}
void TileGenerator::generate(const std::string &input, const std::string &output)
{
@ -238,6 +243,13 @@ void TileGenerator::generate(const std::string &input, const std::string &output
openDb(input_path);
loadBlocks();
if (m_dontWriteEmpty && ! m_positions.size())
{
closeDatabase();
return;
}
createImage();
renderMap();
closeDatabase();

View File

@ -89,6 +89,7 @@ public:
void printGeometry(const std::string &input);
void setZoom(int zoom);
void setScales(uint flags);
void setDontWriteEmpty(bool f);
private:
void parseColorsStream(std::istream &in);
@ -120,6 +121,7 @@ private:
bool m_drawScale;
bool m_drawAlpha;
bool m_shading;
bool m_dontWriteEmpty;
std::string m_backend;
int m_xBorder, m_yBorder;

View File

@ -24,6 +24,7 @@ void usage()
" --draworigin\n"
" --drawalpha\n"
" --noshading\n"
" --noemptyimage\n"
" --min-y <y>\n"
" --max-y <y>\n"
" --backend <backend>\n"
@ -87,6 +88,7 @@ int main(int argc, char *argv[])
{"zoom", required_argument, 0, 'z'},
{"colors", required_argument, 0, 'C'},
{"scales", required_argument, 0, 'f'},
{"noemptyimage", no_argument, 0, 'n'},
{0, 0, 0, 0}
};
@ -195,6 +197,9 @@ int main(int argc, char *argv[])
case 'C':
colors = optarg;
break;
case 'n':
generator.setDontWriteEmpty(true);
break;
default:
exit(1);
}

View File

@ -56,6 +56,10 @@ Allow nodes to be drawn with transparency
.BR \-\-noshading
Don't draw shading on nodes
.TP
.BR \-\-noemptyimage
Don't output anything when the image would be empty.
.TP
.BR \-\-min-y " " \fInumber\fR
Don't draw nodes below this y value, e.g. "--min-y -25"