Skip to content

Commit

Permalink
Release version 1.0
Browse files Browse the repository at this point in the history
- Add version information to the otput
- Add new arguments: -h - help screen, -V - version info
  • Loading branch information
h4tr3d committed Feb 17, 2016
1 parent b55acbd commit 69c650d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ endif ()
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)

# Generate gitinfo
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/)
execute_process(COMMAND git describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE result
OUTPUT_VARIABLE describe
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (${result} EQUAL 0)
add_definitions(-DGEOCROP_VERSION_ADDON="-git+${describe}")
else()
add_definitions(-DGEOCROP_VERSION_ADDON="-git")
endif()
endif()

#find_package(Threads)
#find_package(PkgConfig)

Expand Down
23 changes: 19 additions & 4 deletions geocrop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@
#include <ogr_spatialref.h>
#include <proj_api.h>

#include "version.h"

using namespace std;

static const char *s_options = "f:s:w:ngp:";
static const char *s_options = "f:s:w:ngp:Vh";

void version()
{
cout << "version: " << GEOCROP_VERSION << '\n';
}

void usage(char *name)
{
cout << "Tool for automatic crop raster maps\n";
cout << "(C) Alexander 'hatred' Drozdov, 2012. Distributed under GPLv2 terms\n\n";
cout << "Use: " << name << " [args] <in geodata> [<croped geodata>] [-- [optional gdalwarp arguments]]\n"
cout << "(C) Alexander 'hatred' Drozdov, 2012-2016. Distributed under GPLv2 terms\n";
version();
cout << "\nUse: " << name << " [args] <in geodata> [<croped geodata>] [-- [optional gdalwarp arguments]]\n"
<< " Input geotiff MUST be in RGB pallete, so, use pct2rgb.py to convert from indexed\n"
" Output geotiff croped and nodata areas is transparency\n"
"\n"
Expand All @@ -48,6 +56,10 @@ void usage(char *name)
" Output files with this option will be ignored and can be omited as arguments.\n"
" -p srs_def\n"
" Override projection for dataset\n"
" -V\n"
" Output version and exit.\n"
" -h\n"
" This screen.\n"
;
}

Expand Down Expand Up @@ -230,9 +242,12 @@ int main(int argc, char **argv)
case 'p':
prjFileName = optarg;
break;
case 'V':
version();
return 0;
default:
usage(argv[0]);
return 1;
return opt == 'h' ? 0 : 1;
}
}

Expand Down
10 changes: 10 additions & 0 deletions version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#define GEOCROP_VERSION_BASE "1.0"

#ifndef GEOCROP_VERSION_ADDON
#define GEOCROP_VERSION_ADDON
#endif

#define GEOCROP_VERSION GEOCROP_VERSION_BASE GEOCROP_VERSION_ADDON

0 comments on commit 69c650d

Please sign in to comment.