Code Monkey home page Code Monkey logo

mdaus / nitro Goto Github PK

View Code? Open in Web Editor NEW
60.0 19.0 36.0 186.21 MB

NITRO (NITFio, "R" is a ligature for "Fi") is a full-fledged, extensible library solution for reading and writing the National Imagery Transmission Format (NITF), a U.S. DoD standard format. It is written in cross-platform C, with bindings available for other languages.

License: GNU Lesser General Public License v3.0

Python 5.82% CSS 0.03% HTML 0.12% C++ 43.58% C 49.59% Perl 0.09% Shell 0.03% SWIG 0.42% CMake 0.32%

nitro's Introduction

Building NITRO

CMake is the preferred build method. Version 3.14 or better is required.

Sample Build Scenario

mkdir build
cd build
cmake ..
cmake --build . -j
cmake --build . --target install
ctest

Problems and Configurations

  • If your system compiler does not fully support C++11, you may have to specify a different one during the configure step. e.g.

    cmake -DCMAKE_C_COMPILER=/some/path/gcc/4.9.1/bin/gcc -DCMAKE_CXX_COMPILER=/...../bin/g++ ..
    
  • Pass -DCMAKE_INSTALL_PREFIX to set the install location.

  • Python and C++ bindings are built. Just make sure the relevant tools are on your PATH. Java and MATLAB bindings are now in the archive directory and no longer built.

  • See the coda-oss CMake build README for further build configuration information, particularly for Python-related details. The same options there may be passed to Nitro.

  • Build types Release, RelWithDebInfo, and Debug may be chosen

    • On Linux, debug symbols are available by default (RelWithDebInfo). Configure build type with -DCMAKE_BUILD_TYPE

    • On Windows, release type should be configured during the build and install steps

      cmake --build . --config Release -j
      cmake --build . --config Release --target install
      

      The CMake default build type Debug may not work with Python, unless the Python installation includes debug versions of the Python libraries.

  • Regenerating python bindings

    • Currently, cmake configuration for regenerating swig bindings is incomplete and use of waf is required.

    • The .regenerate_python_bindings.py script is wrapper around waf can be run to quickly update these files.

      python3 .regenerate_python_bindings.py DEBUG_PY_BINDINGS=1 python3 .regenerate_python_bindings.py # see all details

    • This is typically required when project dependencies (e.g. CODA-OSS) are updated.

  • If the CMake build system does not support a required feature that Waf does, create an issue or a pull request!

Building with Waf

Waf is the legacy build system. Below are all of the options available.

> python waf --help
waf [command] [options]

Main commands (example: ./waf build -j4)
  build    : builds the project
  clean    : removes the build files
  configure: configures the project
  dist     : makes a tarball for redistributing the sources
  distcheck: checks if the sources compile (tarball from 'dist')
  install  : installs the build files
  uninstall: removes the installed files

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -j JOBS, --jobs=JOBS  amount of parallel jobs (8)
  -k, --keep            keep running happily on independent task groups
  -v, --verbose         verbosity level -v -vv or -vvv [default: 0]
  --nocache             ignore the WAFCACHE (if set)
  --zones=ZONES         debugging zones (task_gen, deps, tasks, etc)
  -p, --progress        -p: progress bar; -pp: ide output
  --targets=COMPILE_TARGETS
                        build given task generators, e.g. "target1,target2"
  --enable-warnings     Enable warnings
  --enable-debugging    Enable debugging
  --enable-64bit        Enable 64bit builds
  --enable-doxygen      Enable running doxygen
  --with-cflags=FLAGS   Set non-standard CFLAGS
  --with-cxxflags=FLAGS
                        Set non-standard CXXFLAGS (C++)
  --with-defs=DEFS      Use DEFS as macro definitions
  --with-optz=OPTZ      Specify the optimization level for optimized/release builds
  --libs-only           Only build the libs (skip building the tests, etc.)
  --shared              Build all libs as shared libs
  --disable-symlinks    Disable creating symlinks for libs
  --disable-java        Disable java (default)
  --with-java-home=JAVA_HOME
                        Specify the location of the java home
  --require-java        Require Java lib/headers (configure option)
  --nopyc               Do not install bytecode compiled .pyc files (configuration) [Default:install]
  --nopyo               Do not install optimised compiled .pyo files (configuration) [Default:install]
  --disable-python      Disable python
  --require-python      Require Python lib/headers (configure option)
  --enable-openjpeg     Enable openjpeg

  configuration options:
    -b BLDDIR, --blddir=BLDDIR
                        build dir for the project (configuration)
    -s SRCDIR, --srcdir=SRCDIR
                        src dir for the project (configuration)
    --prefix=PREFIX     installation prefix (configuration) [default: '/usr/local/']

  installation options:
    --destdir=DESTDIR   installation root [default: '']
    -f, --force         force file installation

  C Compiler Options:
    --check-c-compiler=CHECK_C_COMPILER
                        On this platform (linux) the following C-Compiler will be checked by default: "gcc icc suncc"

  C++ Compiler Options:
    --check-cxx-compiler=CHECK_CXX_COMPILER
                        On this platform (linux) the following C++ Compiler will be checked by default: "g++ icpc
                        sunc++"

Sample Build Scenario

> python waf configure --enable-debugging --prefix=installed
> python waf build
> python waf install

Enabling a debugger

-g and its variants can be achieved at configure time using the --enable-debugging switch at waf configure time

Memory Debugging

To ease debugging and memory leak detection, macros are used to malloc, realloc and free information. NITF_MALLOC(), NITF_REALLOC(), and NITF_FREE() should be used instead of the stdlib.h functions.

If you defined NITF_DEBUG during compilation (using configure, give the argument --with-defs="-DNITF_DEBUG" and this will occur automatically), you will get an memory image information dump every time you run an executable, named memory_trace.<pid> where <pid> is the PID of the process you just ran. There is a verification tool located in nitf/tests/verify, called mem_sane.pl. If you run mem_sane.pl with the memory trace as the single argument, you will get a formatted output of all memory that is questionably allocated or deallocated in the nitf library's calls. Please, please, please check your stuff.

C Conventions

In order to keep the C code easy to program and debug, and above all, OO, we stick to certain conventions herein:

  • All constructors must be passed an error On failure, they return NULL, and populate the error

  • All destructors must NULL set the object after they are done deleting, and should check the object prior, to make sure that it has not been deleted already. This means, of course, that all destructors take a pointer to the object. In practice, usually most of these, then, take double pointers (where usually you pass it a pointer by address)

  • All objects are in structs with an underscore in front of their name, and a typedef to the real name (.e.g., struct _nitf_PluginRegistry => nitf_PluginRegistry)

  • All functions that are non-static should be wrapped in a NITFAPI(return-val) or NITFPROT(return-val) for protected data.

  • This allows for easy macro definitions in order to control the decoration algorithm for windows, and to assure that the import decoration and export decoration are identical (otherwise we cant use them)

  • IMPORTANT: The difference between NITFAPI() and NITFPROT() is that the C++ code binding generator exposes API() calls and ignores PROT() calls.

  • All enumerations and constants have a NITF/NITF20/NITF21 prefix. Along these lines, all functions and objects are prefixed with a 'namespace' (nitf/nitf20/nitf21).

Platforms

While the ultimate goal is to be cross-platform and cross-language, the C and C++ layers get the most support.

The Python layer gets some use for scripting convenience.

The MATLAB and JAVA layers have not been touched in years; they are no longer built, code remains in the archive directory.

TREs need to be coded in C (only).

Before you commit

  • Create a unit test for your all code you are adding

  • Compile and test. (ctest)

  • A clang-format script is available at externals/coda-oss/.clang-format. Use it.

  • Doxygen on root directory and view in browser the doxygen code (in nitf/doc/html/).

Doxygen Commenting

Please make an effort to write doxygen comments. I know, especially in C, that doxygen has some issues. However, its the best, cheapest thing we have, and its important to have the APIs documented. It will save me the trouble of fixing it later, which will make me eternally grateful.

NITF Library Users: General Issues

NITRO handles TREs by loading dynamic libraries at runtime. Therefore, you need to make sure NITRO can find them.

  • If you are building from source, the location will be compiled in, and you don't have to do anything extra.

  • If you are working from a binary release, you will have to tell NITRO where the plugins are by setting the NITF_PLUGIN_PATH enviornment variable. This should look something like <install>/share/nitf/plugins.

  • If you wish to use a custom TRE location, you can also specify that with NITF_PLUGIN_PATH.

Contact

February 2022, Dan Smith Maxar

nitro's People

Contributors

adam-beauchamp avatar alanlav avatar andrew-hardin avatar anna-dodd avatar asylvest avatar aw-init avatar bradh avatar bryanzeigler avatar christianwhite1193 avatar clydestanfield avatar dj-snyder avatar dstarinshak avatar jdanielsmith avatar jonathanmeans avatar kdwilhelm avatar kjurka avatar porglezomp avatar scolcord avatar tclarke avatar thompsonab avatar trellixvulnteam avatar vkrishna1997 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nitro's Issues

Compiling a C++ app with NITRO

I can build, for example, show_nitf.c from the command line:

gcc show_nitf.c -lnitf-c -lnrt-c -ldl

But trying something similar for show_nitf++.cpp:

g++ show_nitf++.cpp -lnitf-c++ -lnrt-c++ -ldl

Results in:

In file included from /home/user/src/nitro/nitro-NITRO-2.7/installed/include/nitf/Object.hpp:26:0,
                 from /home/user/src/nitro/nitro-NITRO-2.7/installed/include/nitf/LookupTable.hpp:30,
                 from /home/user/src/nitro/nitro-NITRO-2.7/installed/include/nitf/BandInfo.hpp:28,
                 from /home/user/src/nitro/nitro-NITRO-2.7/installed/include/import/nitf.hpp:26,
                 from show_nitf++.cpp:23:
/home/user/src/nitro/nitro-NITRO-2.7/installed/include/nitf/Handle.hpp:71:17: error: ‘Mutex’ in namespace ‘sys’ does not name a type
     static sys::Mutex mutex;

I'm probably missing something...

Memory Leak

char* tempBuf = (char *) NITF_MALLOC(fieldLength);

    if (cursor->desc_ptr->data_type == NITF_BINARY)
    {
        char* tempBuf = (char *) NITF_MALLOC(fieldLength);
        if (!tempBuf)
        {
            nitf_Field_destruct(&field);
            nitf_Error_init(error, NITF_STRERROR(NITF_ERRNO),
                    NITF_CTXT, NITF_ERR_MEMORY);
            return NITF_FAILURE;
        }

        memset(tempBuf, 0, fieldLength);
        nitf_Field_setRawData(field, (NITF_DATA *) tempBuf,
                fieldLength, error);
    }

When formatting a binary field the if{} will exit without freeing tmpBuf

Modifying an NITF header in-place?

I'm looking to add a TRE to an NITF header (or replace it, if it already exists). I see examples of strictly reading or writing, and I could read, modify the Record, then write a copy. But is it possible to modify the header without copying the whole file?

This and the last issue I posted seem possibly better suited to a mailing list than an issue tracker, but nitro-nitf-users over at sourceforge looks abandoned. Let me know if I should ask my questions elsewhere.

What is the best way to populate an external data structure from Nitro

I would like to use Nitro to populate a csm::NitfIsd for CSM.

I am having trouble figuring out how to do this without rereading the file or redoing all the write logic to generate all the parts as strings.

I need:

  • NITF Header as a string
  • Each File TRE as a string
  • Each Image Header as a string
  • Each Image TRE as a string
  • Each DES as a string

At a minimum it would be useful if TREs, DESegments, and ImageSegments also stored the file offset and length(TRE) so that the raw header can be directly read. Alternately I think if the nitf_Writer_write*() methods were public I could write the components to in memory buffers.

Does anyone have any recommendations?

Using openjpeg with NITRO

I noticed a pull request to use OpenJPEG 2.3 instead of 2.0 with NITRO. I just started using NITRO myself and am able to open a NITF 2.1 commercial image and user the JasPer decompression code provided. I noticed that modules\c\j2k\source has implementation files for JasPer, Kakadu, and OpenJPEG, while previous versions of NITRO (e.g. 2.5) had directories under modules\c for JasPer and jpeg that had additional source code files (e.g. JasPerDecompress.c) that enabled JasPer (or purportedly OpenJPEG now) to be used for decompression. With the current NITRO should OpenJPEG "work out of the box" or do I need to write code to have it loaded as a plugin.

thanks,
matthew

Compile NITRO from master with VS2010

I try to compile NITRO from source (Github) with

python waf configure --enable-debugging
python waf build

Unfortunately the build fails with

[371/651] c: c\nrt\source\DirectoryWin32.c -> ..\target\modules\c\nrt\source\DirectoryWin32.c.1.o
DateTime.c
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(105) : error C2143: Syntaxfehler: Es fehlt ';' vor 'Typ'
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(109) : error C2143: Syntaxfehler: Es fehlt ';' vor 'Typ'
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(110) : error C2143: Syntaxfehler: Es fehlt ';' vor 'Typ'
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(111) : error C2065: 'monthIndex': nichtdeklarierter Bezeichner
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(111) : error C2065: 'monthIndex': nichtdeklarierter Bezeichner
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(111) : error C2065: 'monthIndex': nichtdeklarierter Bezeichner
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(114) : error C2065: 'yearIndex': nichtdeklarierter Bezeichner
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(114) : error C2065: 'monthIndex': nichtdeklarierter Bezeichner
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(119) : error C2065: 'lastMonthDays': nichtdeklarierter Bezeichner
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(120) : error C2065: 'monthIndex': nichtdeklarierter Bezeichner
c:\_mydata\projekte\nitro\modules\c\nrt\source\datetime.c(124) : error C2065: 'lastMonthDays': nichtdeklarierter Bezeichner
Debug.c
show_nitf.c
DirectoryWin32.c
Waf: Leaving directory `C:\_MYDATA\Projekte\nitro\target'
Build failed
 -> task in 'nrt-c' failed (exit status 2):
        {task 53241008: c DateTime.c -> DateTime.c.1.o}
['c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\CL.exe', '/nologo', '/UUNICODE', '/U_UNICODE', '/EHs', '/GR', '/W4', '/wd4290', '/wd4512', '/Zi', '/MDd', '', '/IC:\\_MYDATA\\Projekte\\nitro\\target\\modules\\c\\nrt\\include', '/IC:\\_MYDATA\\Projekte\\nitro\\modules\\c\\nrt\\include', '/IC:\\_MYDATA\\Projekte\\nitro\\externals\\coda-oss\\modules\\c++\\include', '/Ic:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE', '/Ic:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE', '/Ic:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include', '/D_CRT_SECURE_NO_WARNINGS', '/D_SCL_SECURE_NO_WARNINGS', '/D_FILE_OFFSET_BITS=64', '/D_LARGEFILE_SOURCE', '/DWIN32', '/D_USE_MATH_DEFINES', '/DNOMINMAX', '/DWIN32_LEAN_AND_MEAN', '/DSWIG_PYTHON_SILENT_MEMLEAK', '/DPYTHONDIR="C:\\_MYDATA\\Projekte\\nitro\\installed\\Lib\\site-packages"', '/DPYTHONARCHDIR="C:\\_MYDATA\\Projekte\\nitro\\installed\\Lib\\site-packages"', '/D_CRT_SECURE_NO_WARNINGS=1', '/D_SCL_SECURE_NO_WARNINGS=1', '/D_LARGEFILE_SOURCE=1', '/DWIN32=1', '/D_USE_MATH_DEFINES=1', '/DNOMINMAX=1', '/DWIN32_LEAN_AND_MEAN=1', '/DSWIG_PYTHON_SILENT_MEMLEAK=1', '/DNRT_MODULE_EXPORTS',
'', '..\\modules\\c\\nrt\\source\\DateTime.c', '/FC', '/c', '/Fo', 'modules\\c\\nrt\\source\\DateTime.c.1.o']

I don't understand the error, because the failing line
datetime.c(105) : error C2143: Syntaxfehler: Es fehlt ';' vor 'Typ'

has no 'Typ', but is
int yearIndex = nrtYearIndex(year);

Any suggestions?

hello world Nitro example

Hello! I was wondering if there is a place where I can find a hello world example of a c++ file using nitro, as well as directions for compilation. I have been struggling a little to figure it out.

Enabling kakadu support for Nitro

I have created a NITF writer using NITRO. I have a kakadu license and want to enable writing j2k compressed files. How do I turn on the kakadu support for NITRO? I know how to do it using GDAL but am trying to do it using Nitro?

I tried waf configure --with-j2k=kdu
I get an error
JPEG2000 library : not found

Building shared libs fails

When building with --shared linking fails, because libjpeg is built as shared lib, but later still expected as static lib.

Build failed
-> missing file: 'C:\\_MYDATA\\Projekte\\nitro\\target\\externals\\coda-oss\\modules\\drivers\\jpeg\\jpeg-9\\libjpeg.lib'

Also there are no "lib" files built under Windows, which are required to use DLLs.

Env: Windows 7, VS2010

Using Plugins in NITRO 2.8 32-Bit

Hello,

I am using the NITRO Library Version 2.8 in my C++ project in order to read and write the data of NITF Files. I can only use a 32-bit version in this project. As the static libraries which are installed with the "...setup.exe" for version 2.8 seem to be 64-bit in both versions (32-bit and 64-bit), I have compiled the code and made new libraries, which works fine so far. I can read and write the data of NITF files, mostly by using the code samples in "test_image_loading++.cpp". The only thing which does not work is using the plugins, which I need in order to compress or decompress the images in the NITF Files (so I can only read uncompressed images so far).

When the image reader is set for a compressed image (in the following line in the writeImage-Function)

nitf::ImageReader deserializer = reader.newImageReader(imageNumber);

there is an exception which says "Decompression handlers not set". This seems to be because the plugin "LibjpegDecompress.dll" which is neccessary for decompression could not be loaded.
My NITF_PLUGIN_PATH is set to the correct path, so the dll file can be found, the problem is that the dll can not be loaded. When i try to load it explicitly with
LoadLibrary("C:\Program Files (x86)\nitro-nitf\nitro-2.8\share\nitf\plugins\LibjpegDecompress.dll");
then i just get a NULL pointer, so it seems this plugin does not fit together with my 32-bit version of the nitf libraries.
Does anyone have the same problems? Is there a 32-bit version of the plugin dlls in version 2.8?
I have also tried to use the 32-bit plugings from older NITRO versions, these can be loaded, but then the reader throws an exception in the "read" command, maybe because the NITRO versions are not the same...

thank you for your help,

Michael

Having issues building on macos sierra/anaconda

I've got the anaconda python distro on OSX sierra with git commit 143b5a7
python waf configure --require-python --python-dev

Setting top to                           : /Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work 
Setting out to                           : /Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work/target 
Platform                                 : darwin 
Checking for 'gcc' (c compiler)          : /usr/bin/gcc 
Checking for 'g++' (c++ compiler)        : /usr/bin/g++ 
Checking for library pthread             : yes 





About to check

Found it
Checking for compiler flags -m64         : no 
System size                              : 32-bit 
Checking for program ant                 : /usr/local/bin/ant 
Checking for program javac               : /usr/bin/javac 
Checking for program java                : /usr/bin/java 
Checking for program jar                 : /usr/bin/jar 
Checking for program javadoc             : /usr/bin/javadoc 
Java lib/headers                         : set JAVA_HOME in the system environment
(complete log in /Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work/target/config.log) 
Checking for program python              : /Users/tclarke/anaconda/bin/python 
Checking for python version              : 2.7.12 
Checking for library python2.7 in LIBPATH_PYEMBED : not found 
Checking for library python2.7 in LIBDIR          : not found 
Checking for library python2.7 in python_LIBPL    : not found 
Checking for library python2.7 in $prefix/libs    : not found 
Checking for library python2.7m in LIBPATH_PYEMBED : not found 
Checking for library python2.7m in LIBDIR          : not found 
Checking for library python2.7m in python_LIBPL    : not found 
Checking for library python2.7m in $prefix/libs    : not found 
Checking for library python27 in LIBPATH_PYEMBED   : not found 
Checking for library python27 in LIBDIR            : not found 
Checking for library python27 in python_LIBPL      : not found 
Checking for library python27 in $prefix/libs      : not found 
Checking for program /Users/tclarke/anaconda/bin/python-config,python2.7-config,python-config-2.7,python2.7m-config : /Users/tclarke/anaconda/bin/python-config 
Checking for header Python.h                                                                                        : :-( 
Asking python-config for pyembed --cflags flags                                                                     : yes 
Asking python-config for pyembed --libs flags                                                                       : yes 
Asking python-config for pyembed --ldflags flags                                                                    : yes 
Getting pyembed flags from python-config                                                                            : Could not build a python embedded interpreter 
The configuration failed
(complete log in /Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work/target/config.log)
The configuration failed
(complete log in /Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work/target/config.log) (Is python built with -fPIC?)
(complete log in /Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work/target/config.log)

Looking at the log, a bunch of config check gcc/g++ builds fail:

Checking for compiler flags -m64
==>

int main(int argc, char **argv) {
        (void)argc; (void)argv;
        return 0;
}

<==
[1/2] ^[[32mcxx: target/.conf_check_fc0af2b517b5a3bcae68c9601d515525/test.cpp -> target/.conf_check_fc0af2b517b5a3bcae68c9601d515525/testbuild/test.cpp.1.o
^[[0m
['/usr/bin/g++', '-fPIC', '-Wall', '-Wno-deprecated-declarations', '-O3', '-m64', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '../test.cpp', '-c', '-o', 'test.cpp.1.o']
[2/2] ^[[33mcxxprogram: target/.conf_check_fc0af2b517b5a3bcae68c9601d515525/testbuild/test.cpp.1.o -> target/.conf_check_fc0af2b517b5a3bcae68c9601d515525/testbuild/testprog
^[[0m
['/usr/bin/g++', '-fPIC', '-Wl,-E', '-m64', 'test.cpp.1.o', '-o', '/Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work/target/.conf_check_fc0af2b517b5a3bcae68c9601d515525/testbuild/testprog']
err: ld: unknown option: -E
clang: error: linker command failed with exit code 1 (use -v to see invocation)

from /Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work: Test does not build: Traceback (most recent call last):
  File "/Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work/externals/coda-oss/build/.waf-1.7.14-6b92f3c95d8c1bad60826036bf26d63f/waflib/Tools/c_config.py", line 459, in run_c_code
    bld.compile()
  File "/Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work/externals/coda-oss/build/.waf-1.7.14-6b92f3c95d8c1bad60826036bf26d63f/waflib/Build.py", line 188, in compile
    raise Errors.BuildError(self.producer.error)
BuildError: Build failed
 -> task in 'testprog' failed (exit status 1):
        {task 4359439440: cxxprogram test.cpp.1.o -> testprog}
['/usr/bin/g++', '-fPIC', '-Wl,-E', '-m64', 'test.cpp.1.o', '-o', '/Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work/target/.conf_check_fc0af2b517b5a3bcae68c9601d515525/testbuild/testprog']

no
from /Users/tclarke/anaconda/conda-bld/nitro_1476285990341/work: The configuration failed

It's getting -Wl,-E from somewhere and failing because -E seems to be a gnu linker option and doesn't work with clang. I can't seem to figure out where it's getting that from. I'm guessing waf is incorrectly guessing those options or has them hard coded.

Multi-threading

Hello,

I'm looking into using the NITRO framework, and was wondering if it supports multi-threaded reads.

Thanks!

Nitro 2.8 release

Hey I was wondering when your next public release is? 2.7 is pretty old and I would like a stable build.

Linking to Nitro c++ with QtCreator

Hi, i am trying to build a simple app with nitro using QtCreator. I made the following steps:

python waf configure --enable-debugging --prefix=installed
python waf build
python waf install

Now i don't know how to link it to my IDE and cannot find the answer, can you guys help?
using Ubuntu 18.04

@edit i also didn't find any info if the nitro library allows to display a nitf image

No module named nitf - Python3

Hi,

I have installed nitro using the following commands -

python waf configure --enable-debugging --disable-matlab --disable-java --require-python --enable-64bit --prefix=installed
python waf build
python waf install

I have also set the environment variable NITF_PLUGIN_PATH to the install/share/nitf/plugins path on my system.

Now my problem is while importing nitf functions on python interpreter -
Upon from nitf import *, I get the error -

ImportError: No module named nitf

How do I fix this? I seem to have followed the instructions to build the library correctly.

ModuleNotFoundError: No module named 'nitf'

my Python environment (Windows 7 & ver 3.7.4), Anaconda

I installed the nitro package ($conda install -c conda-forge nitro). Got installed, now I want to use module import problem

Now my problem is while importing nitf functions on python interpreter -

from nitf import *
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'nitf'

Path seems to be ok.

CMake and other stuff

I wasn't previously aware of this fork, but I had been maintaining one at https://github.com/hobu/nitro for quite a while. My fork mostly just adds CMake support along with a few other small bug fixes. It seems as though you guys are actively updating in support of new efforts, and if you are planning to roll a new release, maybe you are interested in the contributions I've made.

Issues using waf on RHEL 7 including missing references (check.h, sys/time.h, sqrt, pthread)

NITRO 2.7 (we are currently in the process of getting 2.8 (but approval process is not fast)
RHEL: 7.7, Kernal: (uname-r): 3.10.0-1062.12.1.el7.x86_64

The following command fails: python waf configure --enable-debugging --disable-matlab --with-defs="-DNITF_DEBUG" --prefix=../install

I noticed platform=x86_64-unknown-linux-gnu". Should unknown be rhel or redhat? Am I missing an argument?

The command outputs the following as items that were not found: check.h, -lsqrt, -lpthread, sys/time.h related items: BSDgettimeofday, gethrtime, hrtime_t

I noticed the missing sys/time.h related items could be Solaris based. Am I missing an argument to indicate Linux Redhat?

When I remove --with-defs from the configure line then -lpthread is found and the configure succeeds. Is there an issue with using --with-defs? Also, I still get not found messages for the other items above. How do I clean up these items?

This gets me to the point where I can also build successfully and use the libraries. However, I noticed that the j2k shared libraries are missing (J2KCompress|Decompress.so). Is there a specific config parameter to allow the build of thes libraries?

What was the command that was used to build the 2.7 delivered nitro-nitf-2.7-x86_64-linux-gnu-64-41157.zip contents? What was the evironment it was built on (RHEL/GNU/C++/C/Matlab versions, etc.)?

Write CGM Data to NITF File

Hello,

as stated in the issue below, I am using the NITRO Library Version 2.8 in my C++ project in order to read and write the data of NITF Files (32-bit version).
Now I try to read and write graphic segments from and to NITF Files which contain CGM data. Reading the CGM data from a NITF File works fine, I am using the function cgm_MetafileReader_read() from MetafileReader.h to get the data, then I can process the CGM data from the metafile.
The other way does not work yet. I want to create a NITF File with a graphics segment containing CGM data. I tried to use the cgm_MetafileWriter_write() funtion in order to write the CGM data (which is produced in my createCGM() function) to a buffer with the help of an nitf_IOInterface and then write the content of the buffer to the NITF File, but this does not work. The MetafileWriter does not write anything to the nitf_IOInterface. See the code below... Maybe I have to initialize the nitf_IOInterface first? But I don't have a data source in this case for the Interface!?
Can anyone help?

void NitroWrapper::CreateNitfFromCgm(k2::CgmData, const std::string &nitf_path)
{
nitf::Record record;
nitf_Error error;
nitf::ListIterator iter;
nitf::ListIterator end;
char *buffer = NULL;
nitf::Writer writer;

cgm_Metafile *metafile = NULL;
cgm_MetafileWriter *cgm_writer = NULL;
nitf_IOInterface *input = NULL;

/* open the output IO Handle for the NITF File */
nitf::IOHandle output(nitf_path, NITF_ACCESS_WRITEONLY, NITF_CREATE);

populateFileHeader(record, nitf_path);

/* add a graphic segment */
addGraphicSegment(record);

writer.prepare(output, record);

iter = record.getGraphics().begin();
end = record.getGraphics().end();

for (int count = 0; iter != end; ++iter, ++count)
{
	nitf_IOHandle io_handle = nitf_IOHandle();
	input = nitf_IOHandleAdapter_construct(io_handle, NITF_ACCESS_READONLY, &error);

	cgm_writer = cgm_MetafileWriter_construct(&error);
	assert(cgm_writer);

	metafile = createCGM(count, &error);

	// Write CGM Metafile to IO Handle
	cgm_MetafileWriter_write(cgm_writer, metafile, input, &error);

	int size = nrt_IOInterface_getSize(input, &error);

	buffer = new char[size];

	// Read Data from IO Handle and write to Buffer
	nitf_IOHandle_read(input, buffer, size, &error);
	
	nitf::SegmentMemorySource readerSource(buffer, size, 0, 0, true);
	mem::SharedPtr<::nitf::WriteHandler> segmentWriter(new nitf::SegmentWriter(readerSource));
	
	writer.setGraphicWriteHandler(count, segmentWriter);
}

writer.write();

}

Alternate python wrappers

I was trying to use the python wrappers with 3.6 and was having some compatibility issues. Mostly with how strings, bytes, etc. are handled. Since the API isn't the most pythonic interface out there I took a crack at starting a cython based wrapper utilizing buffers, properties, etc. Changed some names to be PEP8 compliant, etc.
It's far from complete at this point since I'm mostly interested in generation right now. Is there any interested in incorporating this into the mainline? Or should I just keep it on my fork?

Format overrun for floating point numbers

Various TRE fields are NITF_BCS_N. From the 2500c specification Sec 5.1.7:

(6)
Basic Character Set-Numeric (BCS-N). The NITF BCS-N is a subset of the BCS
that consists of the digits ‘0’ to ‘9’ (codes 0x30 to 0x39), plus sign (code 0x2B), minus sign (code 0x2D), decimal point
(code 0x2E), and slash (0x2F)

However, on a per-field basis they are limited in size

Example:

in the CSCRNA TRE the ULCNR_LAT field is specified as:

   {NITF_BCS_N,   9,  "lat UL",                 "ULCNR_LAT" },

Which limits the size of 9 characters

NITF Library:

template<> int str::getPrecision(const double& )
{
    return std::numeric_limits<double>::digits10 + 1;
}

passed to

template<typename T> std::string toString(const T& value)
{
    std::ostringstream buf;
    buf.precision(str::getPrecision(value));
    buf << std::boolalpha << value;
    return buf.str();
}

which will return 16. producing numbers such as:

40.450238656509676

which will cause:

    template <typename T> void setField(std::string key, T value)
    {
    	std::string s = str::toString<T>(value);
	    if (!nitf_TRE_setField(getNative(),
	                            key.c_str(),
	                            (NITF_DATA*)s.c_str(),
	                            s.size(),
	                            &error) )
	        throw nitf::NITFException(&error);
    }

nitf_TRE_setField to fail and produce an error. ( see attached test case)
double_field_precision.cpp.txt

The fix/workaround would be to create a function/method that would get the TRE FIELD length and used that as the precision to format to OR perform a substring operation on the formatted string.

Uninstalling Nitro

How does one uninstall nitro? Im working on making a nitro rpm for redhat now and I want to test it... but I have nitro currently installed. Ive tried to do python waf uninstall but that command needs certain arguments and Im not exactly sure what they should be.

Linking to NITRO with Visual Studio 2017

Hey Folks,

Eventually, I will be attempting to write a very simple wrapper for NITRO, so I can access it via C#. (We are only looking to dump the geographic data, and image data; it should be fairly straightforward using the example code you've provided with the installer)

However, just to get started/familiar with NITRO, I am following your guide here (http://nitro-nitf.sourceforge.net/wikka.php?wakka=BuildingVisualStudio), trying to build an executable of the test_image_loading example.

After following the guide, Visual Studio can see the headers and the libs. I should note that I had to include "stdafx.h" in the test code file, as VS complained. When I attempt to build, I am presented with a number of unresolved external symbol errors. Things such as:

LNK2019 unresolves external symbol __imp__iob_func referenced in function getDecomplface (nitf-c.lib (Reader.c.1.0))

Checking the.log file, I can see that I'm getting a linker warning:

LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

So, assuming thats the issue, I head to the properties, Linker->Inputer-Ignore All Default Libraries, and set it to /NODEFAULTLIB

When I rebuild now, I get another pile of unresolved external symbol errors, such as:

unresolved external symbol __stdio_common_vfprintf referencd in fucntion _vfprintf_l

I'll admit to ignorance here, I primarily work with C#. I have created wrappers for other C/C++ libraries in the past (GDAL for example), but the process of configuring VC++ projects is generally very opaque to me. Assuming I can get a little assistance to get the solution up an building, I'm confident I can move onto writing the simple wrapper.

Any suggestions?

ImageWriter constructor fails silently

setNative(nitf_ImageWriter_construct(subheader.getNative(), NULL, &error));

IF the subheader is not properly constructed(i.e. default ctor), this constructor will fail with an error("Compression handlers not set") but the error is not detected. Eventually when attachSource() is invoked, it fails on an 'invalid' handle.

What this leads to is the failure occurring in one place, but showing up someplace else which can be a painful situation to debug.

Suggestion, test for an error in the constructor returning from nitf_ImageWriter_construct and throw unless successful.

C++ round trip issues

Hi, I built and run the test_round_trip.cpp and test_direct_block_round_trip.cpp unfortunately i encountered some issues:

test_direct_block_round_trip.cpp - after running crashes with SIGSEGV, Segmentation fault.
GDB output:
Program received signal SIGSEGV, Segmentation fault.
__memmove_sse2_unaligned_erms ()
at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:403
403 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) bt
#0 __memmove_sse2_unaligned_erms ()
at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:403
#1 0x000055555556642d in TestDirectBlockSource::nextBlock (
this=0x555555879990, buf=0x55555587dc70, block=0x7ffff7f1a010,
blockNumber=0, blockSize=393216) at ../Nitro_usage2/main.cpp:39
#2 0x000055555556feeb in nitf::DirectBlockSource::nextBlock (
callback=0x555555879990, buf=0x55555587dc70, block=0x7ffff7f1a010,
blockNumber=0, blockSize=393216, error=0x7fffffff4ba0)
at ../modules/c++/nitf/source/BandSource.cpp:150
#3 0x00005555555a3db6 in DirectBlockSource_read (data=0x55555587bdc0,
buf=0x55555587dc70, size=1024, error=0x7fffffff4ba0)
at ../modules/c/nitf/source/DirectBlockSource.c:80
#4 0x00005555555b9f50 in ImageWriter_write (data=0x555555874f30,
output=0x555555838530, error=0x7fffffff4ba0)
at ../modules/c/nitf/source/ImageWriter.c:169
#5 0x00005555555cc7e7 in writeImage (imageWriter=0x555555839050,
output=0x555555838530, error=0x7fffffff4ba0)
at ../modules/c/nitf/source/Writer.c:1493
#6 0x00005555555ccef6 in nitf_Writer_write (writer=0x555555871db0,
error=0x7fffffff4ba0) at ../modules/c/nitf/source/Writer.c:1724
#7 0x0000555555582699 in nitf::Writer::write (this=0x7fffffff4b90)
at ../modules/c++/nitf/source/Writer.cpp:80
#8 0x0000555555563cf7 in main (argc=1, argv=0x7fffffffdd58)
---Type to continue, or q to quit---
main.cpp:124

test_round_trip.cpp - should copy input file but it creates a different one

My input data i_3228c.ntf
from https://gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_1/scen_2_1.html

To preview images i used my custom Qt + Gdal viewer:
`
#include
#include
#include <gdal/gdal.h>
#include <gdal/gdal_priv.h>
#include <stdlib.h>
#include
#include
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

qDebug() << "start";

GDALAllRegister();

const char* input = argv[1];
const char* output = argv[2];

GDALDataset * pOldDS;
pOldDS = (GDALDataset*) GDALOpen(input, GA_ReadOnly);

// Get raster image size
int rows = pOldDS->GetRasterBand(1)->GetYSize();
int cols = pOldDS->GetRasterBand(1)->GetXSize();
int channels = pOldDS->GetRasterCount();

// Create each separate image as grayscale
std::vector<cv::Mat> image_list(channels, cv::Mat( rows, cols, CV_8UC1 ));
cv::Mat output_image;

// Iterate over each channel
for (int i = 1; i <= channels; ++i)
 {
    // Fetch the band
    GDALRasterBand* band = pOldDS->GetRasterBand(i);
    // Read the data
    band->RasterIO( GF_Read, 0, 0,
                    cols, rows,
                    image_list[i-1].data,
                    cols, rows,
                    GDT_Byte, 0, 0);
 }

GDALClose(pOldDS);

 // Merge images
 cv::merge( image_list, output_image );

 // Create the QImage
 QImage qt_image( output_image.data,
                  cols,
                  rows,
                  QImage::Format_RGBA8888);

// Do some stuff with the image
QLabel myLabel;
myLabel.setPixmap(QPixmap::fromImage(qt_image));

myLabel.show();

qDebug() << "finish";

return a.exec();

}
`

Reading a J2K compressed NITF using python

Hello,

I have no trouble reading and using data from uncompressed NITF images using python, but I have some that are JPEG2000 compressed and I can't seem to load them. Here is my code up to the point where it reaches an error

from nitf import *

fname = 'path/to/file.NTF'
handle = IOHandle(fname)
reader = Reader()
record = reader.read(handle)
segment = record.getImages()[0]
imReader = reader.newImageReader(0)

The error I get is as follows:

    Exception Traceback (most recent call last)
    <ipython-input-27-1e81730e29ea> in <module>()
    4 record = reader.read(handle)
    5 segment = record.getImages()[0]
    ----> 6 imReader = reader.newImageReader(0)
    7 subheader = segment.subheader

    /usr/lib64/python2.7/site-packages/nitf/init.pyc in newImageReader(self, num)
    327 nbpp = int(self.record.getImages()[num]['numBitsPerPixel'])
    328 reader = nitropy.nitf_Reader_newImageReader(self.ref, num, self.error)
    --> 329 if not reader: raise Exception('Unable to get new ImageReader')
    330 return ImageReader(reader, nbpp)
    331

    Exception: Unable to get new ImageReader

Any help would be greatly appreciated. And if this can't be done in python, I would apreciate any help trying to implement it in c++. I have not worked with nitro outside python, but I will if I have too.

And I am using version 2.7 built from the code on source forge. Is there a reason to rebuild with the code here on github or is it the same.

Thanks

RGB band representation written as all Blue (B) for RGB band in Image Sub Header

When I set the BandInfo in ImageSubHeader::setPixelInformation with RGB bands, the written NITF file shows the all the band representation as [B ] even the BandInfo vector contains RGB bands.

To replicate this, run the test_create_nitf++ program to create the test_create.nitf file, then run the show_nitf++ program on the created test_create.nitf file. Notice the print out "imsub.getBandInfo(i).getRepresentation().toString()" is equal to "[B ]" for all three bands where they should be [R ], [G ], [B ].

I'm using NITRO-2.8 C++ API with Visual Studio 2017.

Question about Python and BANDSB

I'm trying to generate a NITF in Python which contains a BANDSB. I've got some similar code I'm converting from Java. I'm having trouble setting the EXISTENCE_MASK field. My Java code looks something like:

bandsb = new TRE("BANDSB");
Field emf = bandsb.getField("EXISTENCE_MASK");
byte[] emb = emf.getRawData();
emb[3] = 9; // CWAVE[24] and BAD_BAND[27] are set
emf.setRawData(emb);

I can't see how to do something similar in Python. I've tried:

bandsb = nitf.TRE('BANDSB')
bandsb.getField('EXISTENCE_MASK').setString('\00\00\09\00')
print("%04x" % bandsb.getField('EXISTENCE_MASK').intValue())

But I get '0000' suggesting I can't set the binary field this way. How do I set this field?

Compilation Issue Blocking CI/CD

A project I'm working on where we are trying to integrate NITF requires us to set g++ with -Wall -Wextra and -Werror. Any warning produces a build.

in sys/Err.h

    /*!
     *  Constructor
     *  \param errNum  An int to initialize from
     *
     */     
    SocketErr(int errNum = __last_err__)
    {
        setThis(errNum);
    }

Produces this error:

In file included from /usr/local/ornl-six/include/sys/SystemException.h:27:0,
                 from /usr/local/ornl-six/include/sys/MutexInterface.h:29,
                 from /usr/local/ornl-six/include/sys/MutexPosix.h:31,
                 from /usr/local/ornl-six/include/sys/ConditionVarPosix.h:31,
                 from /usr/local/ornl-six/include/sys/ConditionVar.h:53,
                 from /usr/local/ornl-six/include/import/sys.h:28,
                 from /usr/local/ornl-six/include/nitf/Handle.hpp:31,
                 from /usr/local/ornl-six/include/nitf/Object.hpp:26,
                 from /usr/local/ornl-six/include/nitf/Field.hpp:29,
                 from /usr/local/ornl-six/include/nitf/TRE.hpp:28,
                 from ../eovista_nitf/TREs/HISTOA.cpp:38:
/usr/local/ornl-six/include/sys/Err.h: In copy constructor ‘sys::SocketErr::SocketErr(const sys::SocketErr&)’:
/usr/local/ornl-six/include/sys/Err.h:143:5: warning: base class ‘class sys::Err’ should be explicitly initialized in the copy constructor [-Wextra]
     SocketErr(const SocketErr& err)

Modifying the code to:

/*!
     *  Copy constructor.  Takes a right-hand-side
     *  \param err An error to initialize from
     *
     */
    SocketErr(const SocketErr& err)
    : Err(err.getErrID())
    {
    }

Ameliorates the issue for us

Clarify/migrate documentation

I assume that the documentation located at http://nitro-nitf.sourceforge.net/wikka.php?wakka=HomePage is still somehow valid (at least there's much more documentation available than here at Github).

It would be helpful for interested users like me, if this documentation would be migrated to Github as well or if there would be at least a pointer from here to the SF wiki to indicate that this documentation is still valid.

shared build fails on linux

A clean checkout of nitro does not build on the following configuration:

OS: 64-bit CentOS 7
gcc: 4.8.5

I ran the following commands:

> python waf configure --enable-debugging --prefix=installed --shared
> python waf build

And got the following errors:

/bin/ld: cannot find -lnrt-c.2.7
collect2: error: ld returned 1 exit status
/bin/ld: cannot find -lnrt-c.2.7
collect2: error: ld returned 1 exit status
/bin/ld: cannot find -lnrt-c.2.7
collect2: error: ld returned 1 exit status

...

Build failed
-> task in 'test_core_values' failed (exit status 1): {task 24244816: cprogram test_core_values.c.6.o -> test_core_values} ['gcc', '-fPIC', '-Wl,-E', '-m64', '-pthread', 'modules/c/nrt/unittests/test_core_values.c.6.o', '-o', '/home/d/Downloads/nitro-master/target/modules/c/nrt/unittests/test_core_values', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Lmodules/c/nrt', '-lnrt-c.2.7', '-ldl', '-lrt', '-lm']
-> task in 'test_byte_swap' failed (exit status 1): {task 24244496: cprogram test_byte_swap.c.5.o -> test_byte_swap} ['gcc', '-fPIC', '-Wl,-E', '-m64', '-pthread', 'modules/c/nrt/unittests/test_byte_swap.c.5.o', '-o', '/home/d/Downloads/nitro-master/target/modules/c/nrt/unittests/test_byte_swap', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Lmodules/c/nrt', '-lnrt-c.2.7', '-ldl', '-lrt', '-lm']
-> task in 'test_tree' failed (exit status 1): {task 24245648: cprogram test_tree.c.9.o -> test_tree} ['gcc', '-fPIC', '-Wl,-E', '-m64', '-pthread', 'modules/c/nrt/unittests/test_tree.c.9.o', '-o', '/home/d/Downloads/nitro-master/target/modules/c/nrt/unittests/test_tree', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Lmodules/c/nrt', '-lnrt-c.2.7', '-ldl', '-lrt', '-lm']
-> task in 'test_utils' failed (exit status 1): {task 24245904: cprogram test_utils.c.10.o -> test_utils} ['gcc', '-fPIC', '-Wl,-E', '-m64', '-pthread', 'modules/c/nrt/unittests/test_utils.c.10.o', '-o', '/home/d/Downloads/nitro-master/target/modules/c/nrt/unittests/test_utils', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Lmodules/c/nrt', '-lnrt-c.2.7', '-ldl', '-lrt', '-lm']

Is Nitro intended to be used on Linux or is it primarily a Windows library?

TREs parsing on windows, but not on linux

PluginRegistry.canHandleTRE("AIMIDB") returns TRUE on my Windows dev machine, and FALSE on my Linux build machine. As a result, my java code on Windows can see the fields inside of the TREs, but the same code on Linux cannot.

PluginRegistry.canHandleTRE returns FALSE for all TREs on LInux, so it seems like a general issue with the TRE code on Linux.

Unable to build in Windows

I downloaded the source and installed python. I then entered

python waf configure --enable-debugging --prefix=installed
can't open file './build/waf': [Errno 2] No such file or directory

I tested creating the build directory and downloading WAF:

mkdir build
curl -o build/waf https://waf.io/waf-2.0.15

Now at least I got WAF to call.

I tested again

python waf configure --enable-debugging --prefix=installed
Traceback (most recent call last):
File "C:\Repos\nitro-master\build\waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc\waflib\Scripting.py", line 119, in waf_entry_point
run_commands()
File "C:\Repos\nitro-master\build\waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc\waflib\Scripting.py", line 178, in run_commands
parse_options()
File "C:\Repos\nitro-master\build\waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc\waflib\Scripting.py", line 158, in parse_options
ctx.execute()
File "C:\Repos\nitro-master\build\waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc\waflib\Options.py", line 198, in execute
super(OptionsContext,self).execute()
File "C:\Repos\nitro-master\build\waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc\waflib\Context.py", line 85, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "C:\Repos\nitro-master\build\waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc\waflib\Context.py", line 126, in recurse
user_function(self)
File "C:\Repos\nitro-master\wscript", line 15, in options
opt.load(TOOLS + ' msvs dumpenv', tooldir='build')
File "C:\Repos\nitro-master\build\waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc\waflib\Context.py", line 80, in load
module=load_tool(t,path,with_sys_path=with_sys_path)
File "C:\Repos\nitro-master\build\waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc\waflib\Context.py", line 373, in load_tool
import(tool)
ImportError: No module named 'build'

So, I am not sure I am on the right track. What is the problem?

I am running Windows 10 and hoping to get it to work in Visual Studio 2017.

Please, can anyone help me!

error C2664 with VS2010

Sorry to bother again, but with the merge of #63 building with VS2010 fails again:

[118/652] cxx: ..\externals\coda-oss\modules\c++\sys\source\Path.cpp -> ..\target\externals\coda-oss\modules\c++\sys\source\Path.cpp.1.o
FileWin32.cpp
c:\_mydata\projekte\nitro\externals\coda-oss\modules\c++\sys\source\filewin32.cpp(77) : error C2664: 'ReadFile': Konvertierung des Parameters 2 von 'const sys::byte *' in 'LPVOID' nicht möglich        Durch die Konvertierung gehen Qualifizierer verloren
MutexWin32.cpp
OSWin32.cpp
c:\_mydata\projekte\nitro\externals\coda-oss\modules\c++\sys\source\oswin32.cpp(103) : warning C4805: '!=': unsichere Kombination von Typ 'BOOL' mit Typ 'bool' in einer Operation
c:\_mydata\projekte\nitro\externals\coda-oss\modules\c++\sys\source\oswin32.cpp(116) : warning C4805: '!=': unsichere Kombination von Typ 'BOOL' mit Typ 'bool' in einer Operation
c:\_mydata\projekte\nitro\externals\coda-oss\modules\c++\sys\source\oswin32.cpp(318) : warning C4805: '!=': unsichere Kombination von Typ 'BOOL' mit Typ 'bool' in einer Operation
c:\_mydata\projekte\nitro\externals\coda-oss\modules\c++\sys\source\oswin32.cpp(335) : warning C4244: '=': Konvertierung von 'DWORDLONG' in 'size_t', möglicher Datenverlust
c:\_mydata\projekte\nitro\externals\coda-oss\modules\c++\sys\source\oswin32.cpp(336) : warning C4244: '=': Konvertierung von 'DWORDLONG' in 'size_t', möglicher Datenverlust
Path.cpp
Waf: Leaving directory `C:\_MYDATA\Projekte\nitro\target'
Build failed
 -> task in 'sys-c++' failed (exit status 2):
        {task 56772272: cxx FileWin32.cpp -> FileWin32.cpp.1.o}
['c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\CL.exe', '/nologo', '/UUNICODE', '/U_UNICODE', '/EHs', '/GR', '/W4', '/wd4290', '/wd4512', '-Ox', '/MD', '', '/IC:\\_MYDATA\\Projekte\\nitro\\target\\externals\\coda-oss\\modules\\c++\\sys\\include', '/IC:\\_MYDATA\\Projekte\\nitro\\externals\\coda-oss\\modules\\c++\\sys\\include', '/IC:\\_MYDATA\\Projekte\\nitro\\externals\\coda-oss\\modules\\c++\\include', '/IC:\\_MYDATA\\Projekte\\nitro\\target\\externals\\coda-oss\\modules\\c++\\str\\include', '/IC:\\_MYDATA\\Projekte\\nitro\\externals\\coda-oss\\modules\\c++\\str\\include', '/IC:\\_MYDATA\\Projekte\\nitro\\target\\externals\\coda-oss\\modules\\c++\\except\\include', '/IC:\\_MYDATA\\Projekte\\nitro\\externals\\coda-oss\\modules\\c++\\except\\include', '/Ic:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE', '/Ic:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE', '/Ic:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include', '/D_CRT_SECURE_NO_WARNINGS', '/D_SCL_SECURE_NO_WARNINGS', '/D_FILE_OFFSET_BITS=64', '/D_LARGEFILE_SOURCE', '/DWIN32', '/D_USE_MATH_DEFINES', '/DNOMINMAX', '/DWIN32_LEAN_AND_MEAN', '/DSWIG_PYTHON_SILENT_MEMLEAK', '/D_CRT_SECURE_NO_WARNINGS=1', '/D_SCL_SECURE_NO_WARNINGS=1', '/D_LARGEFILE_SOURCE=1', '/DWIN32=1', '/D_USE_MATH_DEFINES=1', '/DNOMINMAX=1', '/DWIN32_LEAN_AND_MEAN=1', '/DSWIG_PYTHON_SILENT_MEMLEAK=1', '', '..\\externals\\coda-oss\\modules\\c++\\sys\\source\\FileWin32.cpp', '/FC', '/c', '/Fo', 'externals\\coda-oss\\modules\\c++\\sys\\source\\FileWin32.cpp.1.o']

NITRO Compilation under Windos 7 and Visual Studio 2010

Firstly... My intention is construct a Visual Studio 2010 project
for reading incrusted jpeg in a nitf file...
for writing jpeg file into nitf file..

Here are the Steps... I do...

Install Python 2.7
Install Visual Studio 2010
Install nitro-nitf-2.7-win64-r1157-setup.exe // From Sourceforge...
/* Download nitro-nitf-2.7-r1157-src No !!*/
Download Nitro Master form Github

Execute cmd with "Visual Studio x64 Win64 Command Prompt (2010)" >>
python .\waf configure

at the path: nitf-master\nitro\

obtaining:



Checking for platform : win32
Checking for program CL : ok c:\Program Files (x86)\Microsoft V
isual Studio 10.0\VC\BIN\x86_ia64\CL.exe
Checking for program CL : ok c:\Program Files (x86)\Microsoft V
isual Studio 10.0\VC\BIN\x86_amd64\CL.exe
Checking for program CL : ok c:\Program Files (x86)\Microsoft V
isual Studio 10.0\VC\BIN\CL.exe
Checking for program CL : ok c:\Program Files (x86)\Microsoft V
isual Studio 10.0\VC\BIN\amd64\CL.exe
Checking for program CL : ok c:\Program Files (x86)\Microsoft V
isual Studio 10.0\VC\BIN\amd64\CL.exe
Checking for program LINK : ok c:\Program Files (x86)\Microsoft V
isual Studio 10.0\VC\BIN\amd64\LINK.exe
Checking for program LIB : ok c:\Program Files (x86)\Microsoft V
isual Studio 10.0\VC\BIN\amd64\LIB.exe
Checking for program MT : ok c:\Program Files (x86)\Microsoft S
DKs\Windows\v7.0A\bin\x64\MT.exe
Checking for program RC : ok c:\Program Files (x86)\Microsoft S
DKs\Windows\v7.0A\bin\x64\RC.exe
Checking for msvc : ok
Checking for msvc : ok
Checking for header inttypes.h : not found
Checking for header unistd.h : not found
Checking for header getopt.h : not found
Checking for header malloc.h : ok
Checking for header sys/time.h : not found
Checking for header dlfcn.h : not found
Checking for header fcntl.h : ok
Checking for header check.h : not found
Checking for header memory.h : ok
Checking for header string.h : ok
Checking for header strings.h : not found
Checking for header stdbool.h : not found
Checking for header stdlib.h : ok
Checking for header stddef.h : ok
Checking for function mmap : not found
Checking for function memmove : ok
Checking for function strerror : ok
Checking for function bcopy : not found
Checking for type size_t : ok
Checking for const keyword : ok
Checking for unsigned short : ok
Checking for unsigned char : ok
Checking for library m : not found
Checking for library rt : not found
Checking for library sqrt : not found
Checking for function gettimeofday : not found
Checking for function clock_gettime : not found
Checking for function BSDgettimeofday : not found
Checking for function gethrtime : not found
Checking for function getpagesize : not found
Checking for function getopt : not found
Checking for function getopt_long : not found
Checking for function isnan : not found
Checking for type hrtime_t : not found
Checking system type sizes : ok
Checking for sizeof long long : 8
Checking for sizeof long : 4
Checking for bigendian : False
Checking for sizeof double : 8
Checking for sizeof short : 2
Checking for sizeof int : 4
Checking for sizeof float : 4
Checking for 64-bit system : ok
Checking for program javac : not found
Checking for program java : not found
Checking for program jar : not found
Checking for program python : ok C:\Python27\python.exe
Checking for Python version : 2.7.13
Checking for library python27 : ok
Checking for program python2.7-config : not found
Checking for program python-config-2.7 : not found
Checking for header Python.h : Could not find the python development
headers
Checking for Python lib/headers : the configuration failed (see 'c:\De
sa\nitf-master\nitro\target\config.log')
Checking for program matlab : not found
Checking for Java lib/headers : set JAVA_HOME in the system environme
nt
'configure' finished successfully (14.286s)


after this.. I execute
c:\Desa\nitf-master\nitro>python .\waf build
obtainig:



Waf: Entering directory c:\Desa\nitf-master\nitro\target' Waf: Leaving directoryc:\Desa\nitf-master\nitro\target'
object 'mem-c++' was not found in uselib_local (required by 'mt-c++')

this ocurs with the source forge 2.7 sources...
with github its ok... >> I achive compile it whith WAF and produce all the Target files...



I´ve contruct a project with
the *.c NITRO FIles... ( DateTime.c .. Utils.c)
the *.c NITF Files... (BandInfo..writer.c)
then I add the file test_image_loading.c for trying read the jpeg image...

In one machine I have problem during the LoadLybrary windows api function (it returns null ... when i try to load all the dlls inside the plugins chapter...)

and in another machine with others dlls, it loads ok but i have the following problem...
I am try to read a NITF file... with the reading example...
obtaining all the header data correctly ... rows=256 columns = 256 jpegcompresion = C3...
But the program crash at READBLOCk IO function... why ?!
Since WAF don´t say which instructions are executing.... If it´s posible to do a compilation without WAF ?

My intention is migrate this library to RTOS vxWorks, but after this, i Want to read and write jpeg image at NITF 2.0 File .

If it´s posible do this in a completely static way... taking the externals plugins as loading objects .o or librarys .a this is... without dll´s ...
Its is posible obtain teh source code of all DLL´s ?! and try to debug it later ?!
Where is the Dll source codes ? (since is installed from the nitro.exe instalation exe file)
Thank you !!

Building NITRO for C

Hello all,

I apologize if my post does not adhere to the guidelines of reporting an issue...

I would like to integrate NITRO API. The following I wish to achieve is...
-unpacking nitf file (extract image) and write to file
-create nitf file with image (jpeg and jpeg2000)

To learn the API, I am using the sample code from NITRO wiki (read nitf file) http://nitro-nitf.sourceforge.net/wikka.php?wakka=ReadRecord15C -- and resolving header path issues after consecutive attempts of compiling.

The problem I am experiencing are a few linker errors,

nitf_reader.c:(.text+0x83): undefined reference to nitf_Reader_getNITFVersion'
nitf_reader.c:(.text+0xd7): undefined reference to nrt_IOHandle_create' nitf_reader.c:(.text+0xf9): undefined reference to nitf_Reader_construct'
nitf_reader.c:(.text+0x12a): undefined reference to nitf_Reader_read' nitf_reader.c:(.text+0x14a): undefined reference to nrt_IOHandle_close'
nitf_reader.c:(.text+0x159): undefined reference to nitf_Record_destruct' nitf_reader.c:(.text+0x168): undefined reference to nitf_Reader_destruct'
nitf_reader.c:(.text+0x194): undefined reference to nrt_Error_print' nitf_reader.c:(.text+0x1aa): undefined reference to nrt_IOHandle_close'
nitf_reader.c:(.text+0x1c5): undefined reference to nitf_Record_destruct' nitf_reader.c:(.text+0x1e0): undefined reference to nitf_Reader_destruct'`

Any suggestions would be greatly appreciated. Thanks!

Cannot set binary fields

gtest run of attached code:

14:30 $ ./bandsb_existence_mask 
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from nitro_bugs
[ RUN      ] nitro_bugs.bandsb_existence_mask
/home/[email protected]/nitro_bugs/bandsb_existence_mask.cpp:37: Failure
Value of: success
  Actual: false
Expected: true
setValue -> invalid dataLength for field: EXISTENCE_MASK
[  FAILED  ] nitro_bugs.bandsb_existence_mask (13 ms)
[----------] 1 test from nitro_bugs (13 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (13 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] nitro_bugs.bandsb_existence_mask

 1 FAILED TEST

/usr/local/include/nitf/TRE.hpp:234

    template <typename T>
    void setField(std::string key, T value) // value = 2575564800
    {
        std::string s = str::toString<T>(value); // AP formats binary value as string "2575564800"
        if (!nitf_TRE_setField(getNative(),
                               key.c_str(),
                               (NITF_DATA*)s.c_str(),
                               s.size(), // APthen uses string as the length 
                               &error))
        {
            throw NITFException(&error);
        }
    }

bandsb nitf_TREDescription

        // {NITF_BINARY, 4,  "Bit-wise Existence Mask Field", "EXISTENCE_MASK" }

len(""2575564800") > 4

working around for now with:

template<typename T>
void setBinaryTREfield(const nitf::TRE& tre, const char* key, T value)
{
    nitf_Error error ;
    auto native_tre = (nitf_TRE *)tre.getNative() ;
    auto success = nitf_TRE_setField(native_tre, key, &value, sizeof(value), &error) ;
    if( ! success )
        throw nitf::NITFException(&error) ;
}

+/- a endian byte-swap we may have another issue pending for that

nitro_bugs.zip

Direct I/O help

I'm looking to perform some direct image I/O and I'm having trouble using some of the existing interfaces and modifying existing code to work for more cases.

  1. I want to efficiently copy segment data to a new NITF (I.E. adding new segments and modifying limited segments but maintaining the rest). I noticed DirectBlockSource but I don't see any example usage. Any pointers on using this interface?
  2. I want to directly write image data without data manipulation by NITRO. The specific case if for large data already in BIP order. I'd rather not convert to BSQ just to convert back to BIP. The interfaces seem to support this if it's only a single band but I'm having trouble modifying it to work with multiple bands. I'd like to just pass a Source and say "write this with no modification" so I can create a MemorySource pointing to my existing data.

Image data spills over to the DataExtensionSegment

This is what I am trying to do:
Write regular TREs
Write Custom TREs as ENGDRA in the DataExtensionSegment
Write multiband image data, compressed, into one segment.

In the output Nitf file, the image data has spilt over to the DataExtensionSegment. The overflow happens when I use all the 7 bands of multispectral data. If I write 1 band or 3 bands then it is fine.

--shared option for Nitro 2.8 yields errors

I'm building Nitro 2.8 on both Windows and Linux. I've encountered problems on both systems using the --shared option to build shared libraries. On Windows I encounter the error:

Build failed
-> missing file:
'C:\nitro-NITRO-2.8\target\externals\coda-oss\modules\drivers\jpeg\jpeg-9\libjpeg.lib'

If I configure and build without --shared, then reconfigure and rebuild with --shared, I can bypass this error to a complete build due to the static libjpeg.lib having been built with the first build, though I have not gotten to the step of linking all of this with our code so not sure what downstream implications this will have.

Clarify license terms

Please clarify the intended licensing in the Readme.md.

I found here at Github the COPYING (for GPLv3) and COPYING.LESSER (for LGPLv3) files.
However in the project settings here GPLv3 is indicated.
The old docs at http://nitro-nitf.sourceforge.net/wikka.php?wakka=HomePage indicate it's LGPLv3.

So is it a dual licensing model (under which conditions?) or only GPLv3 or only LGPLv3?

For me it would be crucial, which license applies, because if I would use NITRO in one of our projects, I could not open the source code (which would dynamically link NITRO) for contractual reasons.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.