mirror of
https://github.com/minetest/minetestmapper.git
synced 2024-11-14 14:40:30 +01:00
Add an option to get the extent of the map.
This commit is contained in:
parent
48d9e0bb42
commit
8e8cc3d1f2
|
@ -77,6 +77,9 @@ draworigin:
|
||||||
drawalpha:
|
drawalpha:
|
||||||
Allow nodes to be drawn with transparency (e.g. water), ``--drawalpha``
|
Allow nodes to be drawn with transparency (e.g. water), ``--drawalpha``
|
||||||
|
|
||||||
|
extent:
|
||||||
|
Don't output any imagery, just print the extent of the full map, ``--extent``
|
||||||
|
|
||||||
noshading:
|
noshading:
|
||||||
Don't draw shading on nodes, ``--noshading``
|
Don't draw shading on nodes, ``--noshading``
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,27 @@ void TileGenerator::parseColorsFile(const std::string &fileName)
|
||||||
parseColorsStream(in);
|
parseColorsStream(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileGenerator::printGeometry(const std::string &input)
|
||||||
|
{
|
||||||
|
string input_path = input;
|
||||||
|
if (input_path[input.length() - 1] != PATH_SEPARATOR) {
|
||||||
|
input_path += PATH_SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
openDb(input_path);
|
||||||
|
loadBlocks();
|
||||||
|
|
||||||
|
std::cout << "Map extent: "
|
||||||
|
<< m_xMin*16 << ":" << m_zMin*16
|
||||||
|
<< "+" << (m_xMax - m_xMin+1)*16
|
||||||
|
<< "+" << (m_zMax - m_zMin+1)*16
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
closeDatabase();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TileGenerator::generate(const std::string &input, const std::string &output)
|
void TileGenerator::generate(const std::string &input, const std::string &output)
|
||||||
{
|
{
|
||||||
string input_path = input;
|
string input_path = input;
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
void parseColorsFile(const std::string &fileName);
|
void parseColorsFile(const std::string &fileName);
|
||||||
void setBackend(std::string backend);
|
void setBackend(std::string backend);
|
||||||
void generate(const std::string &input, const std::string &output);
|
void generate(const std::string &input, const std::string &output);
|
||||||
|
void printGeometry(const std::string &input);
|
||||||
void setZoom(int zoom);
|
void setZoom(int zoom);
|
||||||
void setScales(uint flags);
|
void setScales(uint flags);
|
||||||
|
|
||||||
|
|
11
mapper.cpp
11
mapper.cpp
|
@ -28,6 +28,7 @@ void usage()
|
||||||
" --max-y <y>\n"
|
" --max-y <y>\n"
|
||||||
" --backend <backend>\n"
|
" --backend <backend>\n"
|
||||||
" --geometry x:y+w+h\n"
|
" --geometry x:y+w+h\n"
|
||||||
|
" --extent\n"
|
||||||
" --zoom <zoomlevel>\n"
|
" --zoom <zoomlevel>\n"
|
||||||
" --colors <colors.txt>\n"
|
" --colors <colors.txt>\n"
|
||||||
" --scales [t][b][l][r]\n"
|
" --scales [t][b][l][r]\n"
|
||||||
|
@ -80,6 +81,7 @@ int main(int argc, char *argv[])
|
||||||
{"noshading", no_argument, 0, 'H'},
|
{"noshading", no_argument, 0, 'H'},
|
||||||
{"backend", required_argument, 0, 'd'},
|
{"backend", required_argument, 0, 'd'},
|
||||||
{"geometry", required_argument, 0, 'g'},
|
{"geometry", required_argument, 0, 'g'},
|
||||||
|
{"extent", no_argument, 0, 'E'},
|
||||||
{"min-y", required_argument, 0, 'a'},
|
{"min-y", required_argument, 0, 'a'},
|
||||||
{"max-y", required_argument, 0, 'c'},
|
{"max-y", required_argument, 0, 'c'},
|
||||||
{"zoom", required_argument, 0, 'z'},
|
{"zoom", required_argument, 0, 'z'},
|
||||||
|
@ -95,6 +97,7 @@ int main(int argc, char *argv[])
|
||||||
TileGenerator generator;
|
TileGenerator generator;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
bool onlyPrintExtent = false;
|
||||||
while (1) {
|
while (1) {
|
||||||
c = getopt_long(argc, argv, "hi:o:", long_options, &option_index);
|
c = getopt_long(argc, argv, "hi:o:", long_options, &option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
|
@ -139,6 +142,9 @@ int main(int argc, char *argv[])
|
||||||
case 'e':
|
case 'e':
|
||||||
generator.setDrawAlpha(true);
|
generator.setDrawAlpha(true);
|
||||||
break;
|
break;
|
||||||
|
case 'E':
|
||||||
|
onlyPrintExtent = true;
|
||||||
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
generator.setShading(false);
|
generator.setShading(false);
|
||||||
break;
|
break;
|
||||||
|
@ -206,7 +212,10 @@ int main(int argc, char *argv[])
|
||||||
colors = search_colors(input);
|
colors = search_colors(input);
|
||||||
try {
|
try {
|
||||||
generator.parseColorsFile(colors);
|
generator.parseColorsFile(colors);
|
||||||
generator.generate(input, output);
|
if (onlyPrintExtent)
|
||||||
|
generator.printGeometry(input);
|
||||||
|
else
|
||||||
|
generator.generate(input, output);
|
||||||
} catch(std::runtime_error e) {
|
} catch(std::runtime_error e) {
|
||||||
std::cerr << "Exception: " << e.what() << std::endl;
|
std::cerr << "Exception: " << e.what() << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -72,6 +72,10 @@ Use specific map backend; supported: *sqlite3*, *leveldb*, *redis*, *postgresql*
|
||||||
.BR \-\-geometry " " \fIgeometry\fR
|
.BR \-\-geometry " " \fIgeometry\fR
|
||||||
Limit area to specific geometry (*x:y+w+h* where x and y specify the lower left corner), e.g. "--geometry -800:-800+1600+1600"
|
Limit area to specific geometry (*x:y+w+h* where x and y specify the lower left corner), e.g. "--geometry -800:-800+1600+1600"
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR \-\-extent " " \fIextent\fR
|
||||||
|
Dont render the image, just print the extent of the map that would be generated, in the same format as the geometry above.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-\-zoom " " \fIfactor\fR
|
.BR \-\-zoom " " \fIfactor\fR
|
||||||
Zoom the image by using more than one pixel per node, e.g. "--zoom 4"
|
Zoom the image by using more than one pixel per node, e.g. "--zoom 4"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user