diff --git a/Utilities/GDAL/GNUmakefile b/Utilities/GDAL/GNUmakefile deleted file mode 100644 index a9e736c2ff905aaf22bb8dafb720fb82788ba990..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/GNUmakefile +++ /dev/null @@ -1,205 +0,0 @@ - -WEB_DIR = $(HOME)/www/gdal - -include GDALmake.opt - -GDAL_OBJ = $(GDAL_ROOT)/frmts/o/*.o \ - $(GDAL_ROOT)/gcore/*.o \ - $(GDAL_ROOT)/port/*.o \ - $(GDAL_ROOT)/alg/*.o - -ifeq ($(OGR_ENABLED),yes) -GDAL_OBJ += $(GDAL_ROOT)/ogr/ogrsf_frmts/o/*.o -endif - -include ./ogr/file.lst -GDAL_OBJ += $(addprefix ./ogr/,$(OBJ)) - -LIBGDAL-yes := $(GDAL_LIB) -LIBGDAL-$(HAVE_LD_SHARED) += $(GDAL_SLIB) -# override if we are using libtool -LIBGDAL-$(HAVE_LIBTOOL) := $(LIBGDAL) - -default: lib-target py-target apps-target - -lib-target: check-lib; - -force-lib: - $(AR) r $(GDAL_LIB) $(GDAL_OBJ) - $(RANLIB) $(GDAL_LIB) - $(LD_SHARED) $(GDAL_SLIB_SONAME) $(GDAL_OBJ) $(GDAL_LIBS) $(LIBS) \ - -o $(GDAL_SLIB) - -$(GDAL_LIB): $(GDAL_OBJ) GDALmake.opt - rm -f libgdal.a - $(AR) r $(GDAL_LIB) $(GDAL_OBJ) - $(RANLIB) $(GDAL_LIB) - -$(GDAL_SLIB): $(GDAL_OBJ) - $(LD_SHARED) $(GDAL_SLIB_SONAME) $(GDAL_OBJ) $(GDAL_LIBS) $(LIBS) \ - -o $(GDAL_SLIB) - -$(LIBGDAL): $(GDAL_OBJ:.o=.lo) - $(LD) $(LIBS) -o $@ $(GDAL_OBJ:.o=.lo) \ - -rpath $(INST_LIB) \ - -no-undefined \ - -version-info $(LIBGDAL_CURRENT):$(LIBGDAL_REVISION):$(LIBGDAL_AGE) - -check-lib: port-target core-target frmts-target ogr-target - $(MAKE) $(LIBGDAL-yes) - -port-target: - (cd port; $(MAKE)) - -ogr-target: - (cd ogr; $(MAKE) lib ) - -core-target: - (cd gcore; $(MAKE)) - (cd alg; $(MAKE)) - -frmts-target: - (cd frmts; $(MAKE)) - -ogr-all: - (cd ogr; $(MAKE) all) - -apps-target: lib-target ogr-apps - (cd apps; $(MAKE)) - - -ogr-apps: lib-target - (cd ogr; $(MAKE) apps) - - -# -# We only make python a default target if we think python is installed. -# -ifeq ($(PYTHON),no) -py-target: ; -else -py-target: py-module; -endif - -swig-target: -ifneq ($(BINDINGS),) - (cd swig; $(MAKE) build) -endif - -clean: lclean - (cd port; $(MAKE) clean) - (cd ogr; $(MAKE) clean) - (cd gcore; $(MAKE) clean) - (cd frmts; $(MAKE) clean) - (cd alg; $(MAKE) clean) - (cd apps; $(MAKE) clean) -ifneq ($(BINDINGS),) - (cd swig; $(MAKE) clean) -endif - (cd pymod; $(MAKE) clean) - -py-module: lib-target - (cd pymod; $(MAKE)) - -lclean: - rm -f *.a *.so config.log config.cache html/*.* - $(RM) *.la - -distclean: dist-clean - -dist-clean: clean - rm -f GDALmake.opt port/cpl_config.h config.cache config.status - rm -f libtool - rm -rf autom4te.cache - -config: configure - ./configure - -configure: configure.in aclocal.m4 - autoconf - -GDALmake.opt: GDALmake.opt.in config.status - ./config.status - -docs: - (cd ogr; $(MAKE) docs) - (cd html; rm -f *.*) -# Generate translated docs. Should go first, because index.html page should -# be overwritten with the main one later - doxygen -w html html/header.html html/footer.html html/stylesheet.css - sed -e 's,iso-8859-1,koi8-r,g' html/header.html > html/header_ru.html - (cat Doxyfile ; echo "HTML_HEADER=html/header_ru.html"; echo "INPUT=doc/ru"; echo "OUTPUT_LANGUAGE=Russian") | doxygen - -# Generate HTML docs - doxygen Doxyfile -# Generate man pages - (cat Doxyfile ; echo "ENABLED_SECTIONS=man"; echo "INPUT=doc ogr"; echo "FILE_PATTERNS=*utilities.dox"; echo "GENERATE_HTML=NO"; echo "GENERATE_MAN=YES") | doxygen - - cp data/gdalicon.png html - cp doc/ERMapperlogo_small.gif html - cp frmts/*.html frmts/*/frmt_*.html html - -all: default ogr-all - -install-docs: - (cd ogr; $(MAKE) install-docs) - $(INSTALL_DIR) $(INST_DOCS)/gdal - cp html/*.* $(INST_DOCS)/gdal - -web-update: docs - cp html/*.* $(WEB_DIR) - -install: default install-actions - -install-actions: install-lib - $(INSTALL_DIR) $(INST_BIN) - $(INSTALL_DIR) $(INST_DATA) - $(INSTALL_DIR) $(INST_INCLUDE) - (cd port; $(MAKE) install) - (cd gcore; $(MAKE) install) - (cd frmts; $(MAKE) install) - (cd alg; $(MAKE) install) - (cd ogr; $(MAKE) install) - (cd apps; $(MAKE) install) - (cd man; $(MAKE) install) -ifneq ($(PYTHON),no) - (cd pymod; $(MAKE) install) -endif -ifneq ($(BINDINGS),) - (cd swig; $(MAKE) install) -endif - for f in data/*.* ; do $(INSTALL_DATA) $$f $(INST_DATA) ; done - $(LIBTOOL_FINISH) $(INST_LIB) - -ifeq ($(HAVE_LIBTOOL),yes) - -install-lib: - $(INSTALL_DIR) $(INST_LIB) - for f in $(LIBGDAL-yes) ; do $(INSTALL_LIB) $$f $(INST_LIB) ; done - -else - -ifeq ($(HAVE_LD_SHARED),yes) - -GDAL_VER_MAJOR = $(firstword $(subst ., ,$(GDAL_VER))) -GDAL_SLIB_B = $(notdir $(GDAL_SLIB)) - -install-lib: - $(INSTALL_DIR) $(INST_LIB) - rm -f $(INST_LIB)/$(GDAL_SLIB_B) - rm -f $(INST_LIB)/$(GDAL_SLIB_B).$(GDAL_VER_MAJOR) - rm -f $(INST_LIB)/$(GDAL_SLIB_B).$(GDAL_VER) - $(INSTALL_LIB) $(GDAL_SLIB) $(INST_LIB)/$(GDAL_SLIB_B).$(GDAL_VER) - (cd $(INST_LIB) ; \ - ln -s $(GDAL_SLIB_B).$(GDAL_VER_MAJOR) $(GDAL_SLIB_B)) - (cd $(INST_LIB) ; \ - ln -s $(GDAL_SLIB_B).$(GDAL_VER) $(GDAL_SLIB_B).$(GDAL_VER_MAJOR)) - -else - -install-lib: - $(INSTALL_DIR) $(INST_LIB) - $(INSTALL_LIB) $(GDAL_LIB) $(INST_LIB) - -endif # HAVE_LD_SHARED=no - - -endif # HAVE_LIBTOOL=no diff --git a/Utilities/GDAL/frmts/airsar/GNUmakefile b/Utilities/GDAL/frmts/airsar/GNUmakefile deleted file mode 100644 index d0d08c9b51a6e26dfc8d7c1c96a0efc8c981b694..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/airsar/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = airsardataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/bmp/GNUmakefile b/Utilities/GDAL/frmts/bmp/GNUmakefile deleted file mode 100644 index 2d71d6c079cc82d1ff3378b47761b58efd6e1a1a..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/bmp/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = bmpdataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/bsb/GNUmakefile b/Utilities/GDAL/frmts/bsb/GNUmakefile deleted file mode 100644 index 040ba998d9f69172b6d8362c730bd5771a249fb6..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/bsb/GNUmakefile +++ /dev/null @@ -1,37 +0,0 @@ - - -VERSION = 1.3 - -include ../../GDALmake.opt - -OBJ = bsb_read.o bsbdataset.o - -DISTDIR = bsb-$(VERSION) - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -bsb2raw: bsb2raw.o bsb_read.o - $(CXX) bsb2raw.o bsb_read.o $(GDAL_LIB) $(LIBS) -o bsb2raw - - -install-obj: $(O_OBJ) - -dist: - rm -rf $(DISTDIR) - mkdir $(DISTDIR) - cp *.cpp *.c *.h $(DISTDIR) - rm $(DISTDIR)/bsbdataset.cpp - cp Makefile.dist $(DISTDIR)/Makefile - cp README.dist $(DISTDIR)/README - cp ../../port/{cpl_error*,cpl_port*,cpl_string*} $(DISTDIR) - cp ../../port/{cpl_vsisimple.cpp,cpl_config.h.in} $(DISTDIR) - cp ../../port/{cpl_vsi.h,cpl_conv.*,cpl_path.cpp} $(DISTDIR) - cp ../../port/cpl_config.h.in $(DISTDIR)/cpl_config.h - rm $(DISTDIR)/*.o - tar czf $(DISTDIR).tar.gz $(DISTDIR) - zip -r $(DISTDIR).zip $(DISTDIR) diff --git a/Utilities/GDAL/frmts/ceos2/GNUmakefile b/Utilities/GDAL/frmts/ceos2/GNUmakefile deleted file mode 100644 index 00085532f23c454b2c550e377a178caa52932677..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/ceos2/GNUmakefile +++ /dev/null @@ -1,16 +0,0 @@ - - -OBJ = sar_ceosdataset.o \ - ceosrecipe.o ceossar.o ceos.o link.o - -include ../../GDALmake.opt - - -CPPFLAGS := -I../raw $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/dods/GNUmakefile b/Utilities/GDAL/frmts/dods/GNUmakefile deleted file mode 100644 index 9d5f14608607a69bc339cfb6da9cd1e8574abe36..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/dods/GNUmakefile +++ /dev/null @@ -1,35 +0,0 @@ - - -include ../../GDALmake.opt - -OBJ = dodsdataset2.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) $(DODS_INC) - -default: $(OBJ) - -# By linking with dodsdataset.o explicitly, we don't have to build the -# library to get changes in that code into using_dods for testing. However, -# make sure you do rebuild the library (run make two directories up) once -# you're done. 12/27/02 jhrg -using_dods: using_dods.o dodsdataset.o - $(LD) $(LNK_FLAGS) $^ $(XTRAOBJ) $(CONFIG_LIBS) -o $@$(EXE) - -# There's a note in GDALmake.opt that local programs should link against -# CONFIG_LIBS, but that doesn't work here, maybe because dodsdataset_test -# links statically (which it needs to do to run in a debugger). 10/31/03 jhrg -dodsdataset_test: dodsdataset_test.o dodsdataset.o - $(LD) $(LNK_FLAGS) -static -g3 $^ $(XTRAOBJ) $(LIBS) $(LIBGDAL) \ - -lcppunit -lxml2 -o $@$(EXE) - -docs: - doxygen - -clean: - -rm -f *.o *.lo *~ $(O_OBJ) - -rm -rf docs - -rm -f dodsdataset_test using_dods - -install-obj: $(O_OBJ) - -dodsdataset.o: dodsdataset.cpp dodsdataset.h diff --git a/Utilities/GDAL/frmts/ecw/GNUmakefile b/Utilities/GDAL/frmts/ecw/GNUmakefile deleted file mode 100644 index 2dd935affc09c6586349974b05ccb37a9f965855..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/ecw/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = ecwdataset.o ecwcreatecopy.o jp2userbox.o - -CPPFLAGS := $(GDAL_INCLUDE) -DFRMT_ecw $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/elas/GNUmakefile b/Utilities/GDAL/frmts/elas/GNUmakefile deleted file mode 100644 index 0ebffe049cbfd1340b8b563fff8f9712d50e8843..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/elas/GNUmakefile +++ /dev/null @@ -1,14 +0,0 @@ - - -include ../../GDALmake.opt - -OBJ = elasdataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/envisat/GNUmakefile b/Utilities/GDAL/frmts/envisat/GNUmakefile deleted file mode 100644 index f7cb0682998101856e02396feb721bb345dc47d7..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/envisat/GNUmakefile +++ /dev/null @@ -1,24 +0,0 @@ - -OBJ = EnvisatFile.o envisatdataset.o - -include ../../GDALmake.opt - -XTRA_OPT = -I../raw - -CPPFLAGS := $(GDAL_INCLUDE) $(XTRA_OPT) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -all: $(OBJ) - -install-obj: $(O_OBJ) - -envisat_dump: envisat_dump.o EnvisatFile.o - $(CC) $(CFLAGS) envisat_dump.o EnvisatFile.o $(GDAL_LIB) -ldl -lm -o envisat_dump - -dumpgeo: dumpgeo.o EnvisatFile.o - $(CC) $(CFLAGS) dumpgeo.o EnvisatFile.o $(GDAL_LIB) -ldl -lm -o dumpgeo - diff --git a/Utilities/GDAL/frmts/fit/GNUmakefile b/Utilities/GDAL/frmts/fit/GNUmakefile deleted file mode 100644 index e354abce3bf4657be4c63a088f3d4dc4d66b4e7a..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/fit/GNUmakefile +++ /dev/null @@ -1,15 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = fitdataset.o fit.o - -CPPFLAGS := $(GDAL_INCLUDE) $(XTRA_OPT) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -all: $(OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/fits/GNUmakefile b/Utilities/GDAL/frmts/fits/GNUmakefile deleted file mode 100644 index bad3bb0ad79b2afe99ea8b8fbfb085933ae31aee..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/fits/GNUmakefile +++ /dev/null @@ -1,15 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = fitsdataset.o - -FITS_OPTS = - -CPPFLAGS := $(GDAL_INCLUDE) $(FITS_OPTS) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/gif/GNUmakefile b/Utilities/GDAL/frmts/gif/GNUmakefile deleted file mode 100644 index ccddda8f4f7eaceec27bcf4d73f78d0ae753ac5b..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/gif/GNUmakefile +++ /dev/null @@ -1,26 +0,0 @@ - -include ../../GDALmake.opt - -ifeq ($(GIF_SETTING),internal) -XTRA_OPT = -Ilibungif -OBJ = egif_lib.o dgif_lib.o gifalloc.o gif_err.o \ - \ - gifdataset.o -else -OBJ = gifdataset.o -endif - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) $(XTRA_OPT) - -default: $(O_OBJ) - -clean: - rm -f *.o $(O_OBJ) - -../o/%.o: libungif/%.c - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ - - -all: $(OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/grass/GNUmakefile b/Utilities/GDAL/frmts/grass/GNUmakefile deleted file mode 100644 index e735b1b1d6b965834708449cd890718a0aee48cb..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/grass/GNUmakefile +++ /dev/null @@ -1,28 +0,0 @@ - - -include ../../GDALmake.opt - -#OBJ = grassdataset.o - -ifeq ($(GRASS_SETTING),libgrass) -OBJ = grassdataset.o -else -OBJ = grass57dataset.o -endif - -CPPFLAGS := $(GRASS_INCLUDE) $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) $(OBJ) - -install-obj: $(O_OBJ) - -dist: - cp -r pkg gdal-grass-$(GDAL_VER) - rm -rf gdal-grass-$(GDAL_VER)/CVS - cp grass57dataset.cpp gdal-grass-$(GDAL_VER) - cp ../../ogr/ogrsf_frmts/grass/*.{cpp,h} gdal-grass-$(GDAL_VER) - tar czvf gdal-grass-$(GDAL_VER).tar.gz ./gdal-grass-$(GDAL_VER) - rm -rf gdal-grass-$(GDAL_VER) diff --git a/Utilities/GDAL/frmts/gtiff/GNUmakefile b/Utilities/GDAL/frmts/gtiff/GNUmakefile deleted file mode 100644 index d8a0a6a282b9dbc8b68c6ddac06d052337a0d4a9..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/gtiff/GNUmakefile +++ /dev/null @@ -1,48 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = geotiff.o gt_wkt_srs.o gt_overview.o \ - tif_ovrcache.o tif_overview.o tif_float.o tifvsi.o - -TIFF_OPTS = -SUBLIBS = - -ifeq ($(TIFF_SETTING),internal) -SUBLIBS := lib-tiff $(SUBLIBS) -TIFF_OPTS := -Ilibtiff $(TIFF_OPTS) -endif - -ifeq ($(GEOTIFF_SETTING),internal) -SUBLIBS := lib-geotiff $(SUBLIBS) -TIFF_OPTS := -Ilibgeotiff $(TIFF_OPTS) -endif - -CPPFLAGS := $(GDAL_INCLUDE) $(TIFF_OPTS) $(CPPFLAGS) - -default: $(OBJ) $(SUBLIBS) - -clean: - rm -f *.o $(O_OBJ) - (cd libtiff; $(MAKE) clean) - (cd libgeotiff; $(MAKE) clean) - -gt_test: gt_test.o gt_gs.o cpl_csv.o - $(CC) gt_test.o gt_gs.o cpl_csv.o ../../port/*.o \ - libgeotiff/libgeotiff.a libtiff/libtiff.a $(LIBS) -o gt_test - -gt_write: gt_write.o gt_gs.o cpl_csv.o - $(CC) gt_write.o gt_gs.o cpl_csv.o ../../port/*.o \ - libgeotiff/libgeotiff.a libtiff/libtiff.a $(LIBS) -o gt_write - -epsg_to_wkt: epsg_to_wkt.o gt_wkt_srs.o - $(CXX) epsg_to_wkt.o gt_wkt_srs.o ../../port/*.o \ - libgeotiff/libgeotiff.a libtiff/libtiff.a \ - $(GDAL_LIB) $(LIBS) -o epsg_to_wkt - -lib-tiff: - (cd libtiff; $(MAKE) install-obj) - -lib-geotiff: - (cd libgeotiff; $(MAKE) install-obj) - -install-obj: $(SUBLIBS) $(O_OBJ) diff --git a/Utilities/GDAL/frmts/gxf/GNUmakefile b/Utilities/GDAL/frmts/gxf/GNUmakefile deleted file mode 100644 index 28d4db9e51cb2a97fa89d3866482da6d5fb46660..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/gxf/GNUmakefile +++ /dev/null @@ -1,64 +0,0 @@ -VERSION = 1_0 -DISTDIR = gxf3_$(VERSION) -WEB_DIR = /u/www/projects/gxf -SHARED_LIB = gdal_GXF.so - - -include ../../GDALmake.opt - -GXFOBJ = gxfopen.o gxf_proj4.o gxf_ogcwkt.o -OBJ = gxfdataset.o $(GXFOBJ) - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -gxftest: gxftest.o $(GXFOBJ) - $(CXX) gxftest.o $(GXFOBJ) ../../port/*.o $(LIBS) -o gxftest - -install-obj: $(O_OBJ) - -$(SHARED_LIB): $(OBJ) - $(LD_SHARED) $(OBJ) $(GDAL_SLIB_LINK) $(LIBS) -o $(SHARED_LIB) - -install-lib: $(SHARED_LIB) - cp $(SHARED_LIB) ../../lib - -docs: - rm -rf html - mkdir html - doxygen - -update-web: dist - cp html/* $(WEB_DIR) - cp $(DISTDIR).tar.gz /u/ftp/pub/outgoing - cp $(DISTDIR).zip /u/ftp/pub/outgoing - - -dist: docs - rm -rf $(DISTDIR) - mkdir $(DISTDIR) - mkdir $(DISTDIR)/html - cp html/* $(DISTDIR)/html - autoconf - cp *.c *.h configure Makefile.in $(DISTDIR) - cp makefile.vc.dist $(DISTDIR)/makefile.vc - rm configure - cp ../../port/cpl_conv.cpp $(DISTDIR)/cpl_conv.c - cp ../../port/cpl_conv.h $(DISTDIR) - cp ../../port/cpl_string.cpp $(DISTDIR)/cpl_string.c - cp ../../port/cpl_string.h $(DISTDIR) - cp ../../port/cpl_vsisimple.cpp $(DISTDIR)/cpl_vsisimple.c - cp ../../port/cpl_vsi.h $(DISTDIR) - cp ../../port/cpl_error.cpp $(DISTDIR)/cpl_error.c - cp ../../port/cpl_error.h $(DISTDIR) - cp ../../port/cpl_port.h $(DISTDIR) - cp ../../port/cpl_config.h $(DISTDIR) - cp ../../port/cpl_config.h.in $(DISTDIR) - rm -f $(DISTDIR)/*.o - tar czf $(DISTDIR).tar.gz $(DISTDIR) - zip -r $(DISTDIR).zip $(DISTDIR) - diff --git a/Utilities/GDAL/frmts/hdf4/GNUmakefile b/Utilities/GDAL/frmts/hdf4/GNUmakefile deleted file mode 100644 index f75356873d895307955a8b25bbb44863201f63da..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/hdf4/GNUmakefile +++ /dev/null @@ -1,26 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = hdf4dataset.o hdf4imagedataset.o - -HDFEOS_OPTS = -SUBLIBS = - -HDF4EOS_SETTING = internal -ifeq ($(HDF4EOS_SETTING),internal) -SUBLIBS := lib-hdfeos $(SUBLIBS) -HDFEOS_OPTS := -Ihdf-eos $(HDFEOS_OPTS) -endif - -CPPFLAGS := $(GDAL_INCLUDE) $(HDF4_INCLUDE) $(HDFEOS_OPTS) $(CPPFLAGS) - -default: $(OBJ) $(SUBLIBS) - -clean: - rm -f *.o $(O_OBJ) - (cd hdf-eos; $(MAKE) clean) - -lib-hdfeos: - (cd hdf-eos; $(MAKE) install-obj) - -install-obj: $(SUBLIBS) $(O_OBJ) diff --git a/Utilities/GDAL/frmts/hdf5/GNUmakefile b/Utilities/GDAL/frmts/hdf5/GNUmakefile deleted file mode 100644 index 04ab3fca6eadc1f4561240a29d4de8e3e5f0ecb4..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/hdf5/GNUmakefile +++ /dev/null @@ -1,16 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = hdf5dataset.o hdf5imagedataset.o - -HDFEOS_OPTS = -SUBLIBS = - -CPPFLAGS := $(GDAL_INCLUDE) $(HDF5_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) $(SUBLIBS) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(SUBLIBS) $(O_OBJ) diff --git a/Utilities/GDAL/frmts/ilwis/GNUmakefile b/Utilities/GDAL/frmts/ilwis/GNUmakefile deleted file mode 100644 index ccf229308da2f842f1ccee7ac9288a00be82e3ab..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/ilwis/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = ilwisdataset.o ilwiscoordinatesystem.o - -CPPFLAGS = $(GDAL_INCLUDE) - -default: $(OBJ) - -clean: - rm -f *.o - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/iso8211/GNUmakefile b/Utilities/GDAL/frmts/iso8211/GNUmakefile deleted file mode 100644 index 077746debfa1aa37a7a8cbe50b18737d98ef6282..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/iso8211/GNUmakefile +++ /dev/null @@ -1,91 +0,0 @@ - -include ../../GDALmake.opt - -VERSION = 1.3 -DISTDIR = iso8211lib-$(VERSION) -WEB_DIR = /u/www/projects/iso8211 - -CPPFLAGS := -I. -I../../port $(CPPFLAGS) - -ISOLIB = libiso8211.a -OBJ = ddfmodule.o ddfutils.o ddffielddefn.o ddfrecord.o ddffield.o \ - ddfsubfielddefn.o - -default: $(ISOLIB) - -all: $(ISOLIB) 8211dump 8211view mkcatalog docs - -clean: - rm -rf *.o 8211dump 8211view $(DISTDIR) $(DISTDIR).tar.gz html/* \ - $(ISOLIB) - -dist-clean: clean - rm -rf $(DISTDIR) - -$(ISOLIB): $(OBJ) - $(AR) r $(ISOLIB) $? - $(RANLIB) $(ISOLIB) - -8211dump: 8211dump.o $(ISOLIB) - $(CXX) $(CXX_ODFLAGS) 8211dump.o \ - $(ISOLIB) $(GDAL_LIB) $(LIBS) -o 8211dump - -8211view: 8211view.o $(ISOLIB) - $(CXX) $(CXX_ODFLAGS) 8211view.o \ - $(ISOLIB) $(GDAL_LIB) $(LIBS) -o 8211view - -timetest: timetest.o $(ISOLIB) - $(CXX) $(CXX_ODFLAGS) timetest.o \ - $(ISOLIB) $(GDAL_LIB) $(LIBS) -o timetest - -upd_test: upd_test.o $(ISOLIB) - $(CXX) $(CXX_ODFLAGS) upd_test.o \ - $(ISOLIB) $(GDAL_LIB) $(LIBS) -o upd_test - -mkcatalog: mkcatalog.o $(ISOLIB) - $(CXX) $(CXX_ODFLAGS) mkcatalog.o \ - $(ISOLIB) $(GDAL_LIB) $(LIBS) -o mkcatalog - -docs: - rm -rf html - mkdir html - doxygen - rm html/index.html - cp html/ISO8211Lib.html html/index.html - -dist: docs - rm -rf $(DISTDIR) - mkdir $(DISTDIR) - mkdir $(DISTDIR)/html - cp html/* $(DISTDIR)/html -# mkdir $(DISTDIR)/testdata -# cp testdata/*.* $(DISTDIR)/testdata -# cp teststream.sh teststream.out $(DISTDIR) - autoconf - cp *.cpp *.h configure Makefile.in $(DISTDIR) - rm configure - cp ../../port/{cpl_error*,cpl_port*,cpl_string*} $(DISTDIR) - cp ../../port/{cpl_vsisimple.cpp,cpl_config.h.in} $(DISTDIR) - cp ../../port/{cpl_vsi.h,cpl_conv.*} $(DISTDIR) - cp ../../port/cpl_config.h.vc $(DISTDIR) - rm $(DISTDIR)/*.o - tar czf $(DISTDIR).tar.gz $(DISTDIR) - zip -r $(DISTDIR).zip $(DISTDIR) - -update-web: dist docs - cp html/* $(WEB_DIR) - cp $(DISTDIR).tar.gz $(DISTDIR).zip $(WEB_DIR) - cp $(DISTDIR).tar.gz $(DISTDIR).zip /u/ftp/pub/outgoing - - -test: 8211dump - @./teststream.sh > t1.out - @if test "`diff t1.out teststream.out`" = '' ; then \ - echo "******* Stream 1 Succeeded *********"; \ - rm t1.out; \ - else \ - echo "******* Stream 1 Failed *********"; \ - diff t1.out teststream.out; \ - fi - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/jpeg/GNUmakefile b/Utilities/GDAL/frmts/jpeg/GNUmakefile deleted file mode 100644 index 6cabfec3cd96da45a4b450b3c093ccdc2a1ba1a6..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/jpeg/GNUmakefile +++ /dev/null @@ -1,34 +0,0 @@ - -include ../../GDALmake.opt - -ifeq ($(JPEG_SETTING),internal) -OBJ = \ - jcapimin.o jcapistd.o jccoefct.o jccolor.o jcdctmgr.o jchuff.o \ - jcinit.o jcmainct.o jcmarker.o jcmaster.o jcomapi.o jcparam.o \ - jcphuff.o jcprepct.o jcsample.o jctrans.o jdapimin.o jdapistd.o \ - jdatadst.o jdatasrc.o jdcoefct.o jdcolor.o jddctmgr.o jdhuff.o \ - jdinput.o jdmainct.o jdmarker.o jdmaster.o jdmerge.o jdphuff.o \ - jdpostct.o jdsample.o jdtrans.o jerror.o jfdctflt.o jfdctfst.o \ - jfdctint.o jidctflt.o jidctfst.o jidctint.o jidctred.o jquant1.o \ - jquant2.o jutils.o jmemmgr.o jmemansi.o \ - \ - jpgdataset.o vsidataio.o -XTRA_OPT = -Ilibjpeg -else -OBJ = jpgdataset.o vsidataio.o -XTRA_OPT = -endif - -CPPFLAGS := $(XTRA_OPT) $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -../o/%.o: libjpeg/%.c - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ - -all: $(OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/jpeg2000/GNUmakefile b/Utilities/GDAL/frmts/jpeg2000/GNUmakefile deleted file mode 100644 index 97a623df6f235712d5b0687bc03c6a7f21ef5a7a..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/jpeg2000/GNUmakefile +++ /dev/null @@ -1,14 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = jpeg2000dataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(JASPER_INCLUDE) $(JASPER_FLAGS) $(CPPFLAGS) -CXXFLAGS += -g -O2 - -default: $(OBJ) - -clean: - rm -f $(OBJ) $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/l1b/GNUmakefile b/Utilities/GDAL/frmts/l1b/GNUmakefile deleted file mode 100644 index b606f73d207df882278538daa28a306c959b9552..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/l1b/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = l1bdataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/mem/GNUmakefile b/Utilities/GDAL/frmts/mem/GNUmakefile deleted file mode 100644 index 370f04f74107efbbb7404a6827a6825b9d9d0ccc..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/mem/GNUmakefile +++ /dev/null @@ -1,17 +0,0 @@ - - -include ../../GDALmake.opt - -OBJ = memdataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) - -install: - $(INSTALL_DATA) memdataset.h $(INST_INCLUDE) diff --git a/Utilities/GDAL/frmts/mrsid/GNUmakefile b/Utilities/GDAL/frmts/mrsid/GNUmakefile deleted file mode 100644 index 53753fd417a7bc22cea73f4ad76a6fa70119ec28..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/mrsid/GNUmakefile +++ /dev/null @@ -1,17 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = mrsiddataset.o - -ifeq ($(GEOTIFF_SETTING),internal) -GEOTIFF_INCLUDE = -I../../frmts/gtiff/libgeotiff -endif - -CPPFLAGS := $(GDAL_INCLUDE) $(MRSID_FLAGS) $(MRSID_INCLUDE) $(GEOTIFF_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/msg/GNUmakefile b/Utilities/GDAL/frmts/msg/GNUmakefile deleted file mode 100644 index 82564825928993d09d5253a95228040361801dd2..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/msg/GNUmakefile +++ /dev/null @@ -1,20 +0,0 @@ - -VPATH = PublicDecompWT/DISE/:PublicDecompWT/COMP/Src/:PublicDecompWT/COMP/WT/Src/ - -include ../../GDALmake.opt - -OBJ1=$(patsubst %.cpp,%.o,$(wildcard PublicDecompWT/COMP/WT/Src/*.cpp)) -OBJ2=$(patsubst %.cpp,%.o,$(wildcard PublicDecompWT/COMP/Src/*.cpp)) -OBJ3=$(patsubst %.cpp,%.o,$(wildcard PublicDecompWT/DISE/*.cpp)) -WTOBJ=$(subst PublicDecompWT/COMP/WT/Src/, ,$(OBJ1)) $(subst PublicDecompWT/COMP/Src/, , $(OBJ2)) $(subst PublicDecompWT/DISE/, , $(OBJ3)) - -OBJ = msgdataset.o xritheaderparser.o prologue.o msgcommand.o reflectancecalculator.o $(WTOBJ) - -CPPFLAGS = $(GDAL_INCLUDE) -I PublicDecompWT/DISE -I PublicDecompWT/COMP/WT/Inc -I PublicDecompWT/COMP/Inc -I. - -default: $(OBJ) - -clean: - rm -f *.o - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/msgn/GNUmakefile b/Utilities/GDAL/frmts/msgn/GNUmakefile deleted file mode 100644 index 7763d4cd85a1c0f0115af136720865d19447d560..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/msgn/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = msgndataset.o msg_basic_types.o msg_reader_core.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) -I. -DGDAL_SUPPORT - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/nitf/frmt_nitf.html b/Utilities/GDAL/frmts/nitf/frmt_nitf.html new file mode 100644 index 0000000000000000000000000000000000000000..812b5dc43cec8f91588668237ee6b17cf1e79ba7 --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/frmt_nitf.html @@ -0,0 +1,96 @@ +<html> +<head> +<title>NITF -- National Imagery Transmission Format</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>NITF -- National Imagery Transmission Format</h1> + +GDAL supports reading of several subtypes of NITF image files, and writing +simple uncompressed NITF 2.1 files. NITF 1.1, NITF 2.0 and NITF 2.1 +files with uncomprssed or VQ compressed images should be readable. +JPEG2000 compressed images are also supported, but only if GDAL also has +the JP2KAK driver enabled. Other compression mechanisms are not supported +at this time. The read support test has been tested on CIB and CADRG RPF +products.<p> + +NITF files can contain several images as well as other layers such as +graphics (CGM) and text. Currently GDAL will only read the first image. All +other images and auxilary information are ignored.<p> + +Color tables for pseudocolored images are read. In some cases nodata values +may be identified. Lat/Long extents are read from the IGEOLO information in +the image header if available. Other coordinates systems (such as MGRS) are +ignored at this time. If high precision lat/long georeferencing information +is available in RPF auxilary data it will be used in preference to the low +precision IGEOLO information. In theory all input pixel types except 1bit are +supported, but only 8bit types have actually been tested.<p> + +Most file header and image header fields are returned as dataset level +metadata.<p> + +<h2>Creation Issues</h2> + +On export NITF files are always written as NITF 2.1 with one uncompressed image +and no other auxilary layers. Georeferencing can only be written for +images using a geographic coordinate system. Coordinates are implicitly +treated as WGS84 even if they are actually in a different geographic coordinate +system. Pseudo-color tables may be written for 8bit images.<P> + +In addition to the export oriented CreateCopy() API, it is also possible to +create a blank NITF file using Create() and write imagery on demand. However, +using this methology writing of pseudocolor tables and georeferencing is +not supported unless appropriate IREP and ICORDS creation options are supplied. +<p> + +Creation Options:<p> + +<ul> + +<li> Most file header, and imagery header metadata and security fields can +be set with appropriate creation options. For instance setting +<tt>"FTITLE=Image of abandoned missle silo south west of Karsk"</tt> in the +creation option list would result in setting of the FTITLE field in the NITF +file header. Use the official field names from the NITF specification +document.<p> + +<li> <b>ICORDS</b>: Set to "G" to ensure that space will be reserved for +geographic corner coordinates to be set later via SetGeoTransform(). (Only +needed for Create() method, not CopyCreate()).<p> + +<li> <b>IREP</b>: Set to "RGB/LUT" to reserve space for a color table for +each output band. (Only needed for +Create() method, not CopyCreate()).<p> + +<li> <b>LUT_SIZE</b>: Set to control the size of pseudocolor tables for +RGB/LUT bands. A value of 256 assumed if not present. (Only needed for +Create() method, not CopyCreate()).<p> + +<li> <b>TFW=YES</b>: Force the generation of an associated ESRI world +file (.tfw).<p> + +<li> <b>BLOCKXSIZE=n</b>: Set the block width.<p> + +<li> <b>BLOCKYSIZE=n</b>: Set the block height.<p> + +</ul> + +<h2>Credit</h2> + +The author wishes to thank <a href="http://www.augsignals.com/">AUG +Signals</a> and the <a href="http://geoconnections.org/">GeoConnections</a> +program for supporting development of this driver.<p> + +See Also: <p> +<ul> +<li> <a href="http://164.214.2.51/ntb/">NITFS Technical Board Public Page</a> +<li> The <a href="frmt_ogdi.html">OGDI</a> driver support many NITF based RPF +products including CIB and ADRG.<p> +</ul> + +</body> +</html> + + + diff --git a/Utilities/GDAL/frmts/nitf/mgrs.h b/Utilities/GDAL/frmts/nitf/mgrs.h new file mode 100644 index 0000000000000000000000000000000000000000..b52db87760553dfb669252a550e2e1f927fc43ff --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/mgrs.h @@ -0,0 +1,264 @@ +#ifndef MGRS_H + #define MGRS_H + +/*************************************************************************** + * $Id$ + * + * Project: MGRS Converter + * Purpose: Geotrans declarations for MGRS translation (slightly adapted) + * Author: Unknown (NIMA) + * + *************************************************************************** + * $Log: mgrs.h,v $ + * Revision 1.1 2004/02/09 05:04:00 warmerda + * New + * + *************************************************************************** + * RSC IDENTIFIER: MGRS + * + * ABSTRACT + * + * This component converts between geodetic coordinates (latitude and + * longitude) and Military Grid Reference System (MGRS) coordinates. + * + * ERROR HANDLING + * + * This component checks parameters for valid values. If an invalid value + * is found, the error code is combined with the current error code using + * the bitwise or. This combining allows multiple error codes to be + * returned. The possible error codes are: + * + * MGRS_NO_ERROR : No errors occurred in function + * MGRS_LAT_ERROR : Latitude outside of valid range + * (-90 to 90 degrees) + * MGRS_LON_ERROR : Longitude outside of valid range + * (-180 to 360 degrees) + * MGRS_STR_ERROR : An MGRS string error: string too long, + * too short, or badly formed + * MGRS_PRECISION_ERROR : The precision must be between 0 and 5 + * inclusive. + * MGRS_A_ERROR : Semi-major axis less than or equal to zero + * MGRS_INV_F_ERROR : Inverse flattening outside of valid range + * (250 to 350) + * MGRS_EASTING_ERROR : Easting outside of valid range + * (100,000 to 900,000 meters for UTM) + * (0 to 4,000,000 meters for UPS) + * MGRS_NORTHING_ERROR : Northing outside of valid range + * (0 to 10,000,000 meters for UTM) + * (0 to 4,000,000 meters for UPS) + * MGRS_ZONE_ERROR : Zone outside of valid range (1 to 60) + * MGRS_HEMISPHERE_ERROR : Invalid hemisphere ('N' or 'S') + * + * REUSE NOTES + * + * MGRS is intended for reuse by any application that does conversions + * between geodetic coordinates and MGRS coordinates. + * + * REFERENCES + * + * Further information on MGRS can be found in the Reuse Manual. + * + * MGRS originated from : U.S. Army Topographic Engineering Center + * Geospatial Information Division + * 7701 Telegraph Road + * Alexandria, VA 22310-3864 + * + * LICENSES + * + * None apply to this component. + * + * RESTRICTIONS + * + * + * ENVIRONMENT + * + * MGRS was tested and certified in the following environments: + * + * 1. Solaris 2.5 with GCC version 2.8.1 + * 2. Windows 95 with MS Visual C++ version 6 + * + * MODIFICATIONS + * + * Date Description + * ---- ----------- + * 16-11-94 Original Code + * 15-09-99 Reengineered upper layers + * + */ + + +/***************************************************************************/ +/* + * DEFINES + */ + + #define MGRS_NO_ERROR 0x0000 + #define MGRS_LAT_ERROR 0x0001 + #define MGRS_LON_ERROR 0x0002 + #define MGRS_STRING_ERROR 0x0004 + #define MGRS_PRECISION_ERROR 0x0008 + #define MGRS_A_ERROR 0x0010 + #define MGRS_INV_F_ERROR 0x0020 + #define MGRS_EASTING_ERROR 0x0040 + #define MGRS_NORTHING_ERROR 0x0080 + #define MGRS_ZONE_ERROR 0x0100 + #define MGRS_HEMISPHERE_ERROR 0x0200 + + +/***************************************************************************/ +/* + * FUNCTION PROTOTYPES + */ + +/* ensure proper linkage to c++ programs */ + #ifdef __cplusplus +extern "C" { + #endif + + + long Set_MGRS_Parameters(double a, + double f, + char *Ellipsoid_Code); +/* + * The function Set_MGRS_Parameters receives the ellipsoid parameters and sets + * the corresponding state variables. If any errors occur, the error code(s) + * are returned by the function, otherwise MGRS_NO_ERROR is returned. + * + * a : Semi-major axis of ellipsoid in meters (input) + * f : Flattening of ellipsoid (input) + * Ellipsoid_Code : 2-letter code for ellipsoid (input) + */ + + + void Get_MGRS_Parameters(double *a, + double *f, + char *Ellipsoid_Code); +/* + * The function Get_MGRS_Parameters returns the current ellipsoid + * parameters. + * + * a : Semi-major axis of ellipsoid, in meters (output) + * f : Flattening of ellipsoid (output) + * Ellipsoid_Code : 2-letter code for ellipsoid (output) + */ + + + long Convert_Geodetic_To_MGRS (double Latitude, + double Longitude, + long Precision, + char *MGRS); +/* + * The function Convert_Geodetic_To_MGRS converts geodetic (latitude and + * longitude) coordinates to an MGRS coordinate string, according to the + * current ellipsoid parameters. If any errors occur, the error code(s) + * are returned by the function, otherwise MGRS_NO_ERROR is returned. + * + * Latitude : Latitude in radians (input) + * Longitude : Longitude in radians (input) + * Precision : Precision level of MGRS string (input) + * MGRS : MGRS coordinate string (output) + * + */ + + + long Convert_MGRS_To_Geodetic (char *MGRS, + double *Latitude, + double *Longitude); +/* + * This function converts an MGRS coordinate string to Geodetic (latitude + * and longitude in radians) coordinates. If any errors occur, the error + * code(s) are returned by the function, otherwise MGRS_NO_ERROR is returned. + * + * MGRS : MGRS coordinate string (input) + * Latitude : Latitude in radians (output) + * Longitude : Longitude in radians (output) + * + */ + + + long Convert_UTM_To_MGRS (long Zone, + char Hemisphere, + double Easting, + double Northing, + long Precision, + char *MGRS); +/* + * The function Convert_UTM_To_MGRS converts UTM (zone, easting, and + * northing) coordinates to an MGRS coordinate string, according to the + * current ellipsoid parameters. If any errors occur, the error code(s) + * are returned by the function, otherwise MGRS_NO_ERROR is returned. + * + * Zone : UTM zone (input) + * Hemisphere : North or South hemisphere (input) + * Easting : Easting (X) in meters (input) + * Northing : Northing (Y) in meters (input) + * Precision : Precision level of MGRS string (input) + * MGRS : MGRS coordinate string (output) + */ + + + long Convert_MGRS_To_UTM (char *MGRS, + long *Zone, + char *Hemisphere, + double *Easting, + double *Northing); +/* + * The function Convert_MGRS_To_UTM converts an MGRS coordinate string + * to UTM projection (zone, hemisphere, easting and northing) coordinates + * according to the current ellipsoid parameters. If any errors occur, + * the error code(s) are returned by the function, otherwise UTM_NO_ERROR + * is returned. + * + * MGRS : MGRS coordinate string (input) + * Zone : UTM zone (output) + * Hemisphere : North or South hemisphere (output) + * Easting : Easting (X) in meters (output) + * Northing : Northing (Y) in meters (output) + */ + + + + long Convert_UPS_To_MGRS ( char Hemisphere, + double Easting, + double Northing, + long Precision, + char *MGRS); + +/* + * The function Convert_UPS_To_MGRS converts UPS (hemisphere, easting, + * and northing) coordinates to an MGRS coordinate string according to + * the current ellipsoid parameters. If any errors occur, the error + * code(s) are returned by the function, otherwise UPS_NO_ERROR is + * returned. + * + * Hemisphere : Hemisphere either 'N' or 'S' (input) + * Easting : Easting/X in meters (input) + * Northing : Northing/Y in meters (input) + * Precision : Precision level of MGRS string (input) + * MGRS : MGRS coordinate string (output) + */ + + + long Convert_MGRS_To_UPS ( char *MGRS, + char *Hemisphere, + double *Easting, + double *Northing); +/* + * The function Convert_MGRS_To_UPS converts an MGRS coordinate string + * to UPS (hemisphere, easting, and northing) coordinates, according + * to the current ellipsoid parameters. If any errors occur, the error + * code(s) are returned by the function, otherwide UPS_NO_ERROR is returned. + * + * MGRS : MGRS coordinate string (input) + * Hemisphere : Hemisphere either 'N' or 'S' (output) + * Easting : Easting/X in meters (output) + * Northing : Northing/Y in meters (output) + */ + + + + #ifdef __cplusplus +} + #endif + +#endif /* MGRS_H */ diff --git a/Utilities/GDAL/frmts/nitf/nitfdataset.cpp b/Utilities/GDAL/frmts/nitf/nitfdataset.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c0ef0d29e9c4918fafa51cf5f3c10c2b254e830 --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/nitfdataset.cpp @@ -0,0 +1,2010 @@ +/****************************************************************************** + * $Id: nitfdataset.cpp,v 1.51 2006/01/05 23:12:03 fwarmerdam Exp $ + * + * Project: NITF Read/Write Translator + * Purpose: GDALDataset/GDALRasterBand implementation on top of "nitflib". + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2002, Frank Warmerdam + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ****************************************************************************** + * + * $Log: nitfdataset.cpp,v $ + * Revision 1.51 2006/01/05 23:12:03 fwarmerdam + * Added subdataset support to access multiple images in one file. + * + * Revision 1.50 2005/12/21 01:06:29 fwarmerdam + * Added IMAGE_STRUCTURE COMPRESSION support. + * + * Revision 1.49 2005/10/03 17:39:45 fwarmerdam + * fixed memory leak of GCPs as per bug 920 + * + * Revision 1.48 2005/09/19 21:55:24 gwalter + * Avoid creating gcps when geotransform already found. + * + * Revision 1.47 2005/09/14 12:54:40 dron + * Avoid possible using of uninitialized value. + * + * Revision 1.46 2005/09/14 01:12:52 fwarmerdam + * Removed complex types from creatable formats, apparently not + * currently supported. + * + * Revision 1.45 2005/07/28 20:00:57 fwarmerdam + * upgrade to support 2-4GB files, use large file api + * + * Revision 1.44 2005/05/23 06:57:36 fwarmerdam + * fix flushing to go through pam + * + * Revision 1.43 2005/05/05 15:54:49 fwarmerdam + * PAM Enabled + * + * Revision 1.42 2005/04/18 17:58:12 fwarmerdam + * fixed up ICORDS=' ' case to mean no geotransform + * + * Revision 1.41 2005/04/18 15:45:17 gwalter + * Check for Space Imaging style .hdr + .nfw, and + * default to these rather than in-file geocoding + * information if both files are present and have + * recognizable information. + * + * Revision 1.40 2005/04/18 13:40:22 fwarmerdam + * Remove the default geotransform if we don't have a valid geotransform. + * + * Revision 1.39 2005/03/21 16:25:41 fwarmerdam + * When writing IGEOLO adjust for center of corner pixels instead of + * outer image corners. Also support generating geotransform from + * rotated IGEOLO values. + * + * Revision 1.38 2005/03/17 19:34:31 fwarmerdam + * Added IC and IMODE metadata. + * + * Revision 1.37 2005/03/01 14:28:06 fwarmerdam + * Added support for overriding JPEG2000 profile. + * + * Revision 1.36 2005/02/25 17:01:18 fwarmerdam + * forward AdviseRead and IRasterIO on dataset to j2kdataset if needed + * + * Revision 1.35 2005/02/24 15:11:23 fwarmerdam + * fixed improper j2kdataset cleanup in ~NITFDataset + * + * Revision 1.34 2005/02/22 08:20:58 fwarmerdam + * ensure we can capture color interp on jpeg2000 streams + * + * Revision 1.33 2005/02/18 19:29:16 fwarmerdam + * added SetColorIntepretation support: bug 752 + * + * Revision 1.32 2005/02/10 04:49:31 fwarmerdam + * added color interpretation setting on J2K bands + * + * Revision 1.31 2005/02/08 05:46:33 fwarmerdam + * Fixed up ~NITFDataset() image length/COMRAT patching. + * + * Revision 1.30 2005/02/08 05:20:16 fwarmerdam + * preliminary implementation of JPEG2000 support via Create() + * + * Revision 1.29 2005/01/28 03:47:26 fwarmerdam + * Fixed return value of SetGeoTransform(). + * + * Revision 1.28 2005/01/15 07:47:20 fwarmerdam + * enable NPJE profile + */ + +#include "gdal_pam.h" +#include "nitflib.h" +#include "ogr_spatialref.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: nitfdataset.cpp,v 1.51 2006/01/05 23:12:03 fwarmerdam Exp $"); + +static void NITFPatchImageLength( const char *pszFilename, + long nImageOffset, + GIntBig nPixelCount ); + +static GDALDataset *poWritableJ2KDataset = NULL; +static CPLErr NITFSetColorInterpretation( NITFImage *psImage, + int nBand, + GDALColorInterp eInterp ); + +/************************************************************************/ +/* ==================================================================== */ +/* NITFDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class NITFRasterBand; + +class NITFDataset : public GDALPamDataset +{ + friend class NITFRasterBand; + + NITFFile *psFile; + NITFImage *psImage; + + GDALDataset *poJ2KDataset; + int bJP2Writing; + + int bGotGeoTransform; + double adfGeoTransform[6]; + + char *pszProjection; + + int nGCPCount; + GDAL_GCP *pasGCPList; + char *pszGCPProjection; + + public: + NITFDataset(); + ~NITFDataset(); + + virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize, + int nBufXSize, int nBufYSize, + GDALDataType eDT, + int nBandCount, int *panBandList, + char **papszOptions ); + + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int *, int, int, int ); + + virtual const char *GetProjectionRef(void); + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + + virtual void FlushCache(); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset * + NITFCreateCopy( const char *pszFilename, GDALDataset *poSrcDS, + int bStrict, char **papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ); + +}; + +/************************************************************************/ +/* ==================================================================== */ +/* NITFRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class NITFRasterBand : public GDALPamRasterBand +{ + friend class NITFDataset; + + NITFImage *psImage; + + GDALColorTable *poColorTable; + + public: + NITFRasterBand( NITFDataset *, int ); + ~NITFRasterBand(); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + + virtual GDALColorInterp GetColorInterpretation(); + virtual CPLErr SetColorInterpretation( GDALColorInterp ); + virtual GDALColorTable *GetColorTable(); + virtual CPLErr SetColorTable( GDALColorTable * ); + virtual double GetNoDataValue( int *pbSuccess = NULL ); +}; + + +/************************************************************************/ +/* NITFRasterBand() */ +/************************************************************************/ + +NITFRasterBand::NITFRasterBand( NITFDataset *poDS, int nBand ) + +{ + NITFBandInfo *psBandInfo = poDS->psImage->pasBandInfo + nBand - 1; + + this->poDS = poDS; + this->nBand = nBand; + + this->eAccess = poDS->eAccess; + this->psImage = poDS->psImage; + +/* -------------------------------------------------------------------- */ +/* Translate data type(s). */ +/* -------------------------------------------------------------------- */ + if( psImage->nBitsPerSample <= 8 ) + eDataType = GDT_Byte; + else if( psImage->nBitsPerSample == 16 + && EQUAL(psImage->szPVType,"SI") ) + eDataType = GDT_Int16; + else if( psImage->nBitsPerSample == 16 ) + eDataType = GDT_UInt16; + else if( psImage->nBitsPerSample == 32 + && EQUAL(psImage->szPVType,"SI") ) + eDataType = GDT_Int32; + else if( psImage->nBitsPerSample == 32 + && EQUAL(psImage->szPVType,"R") ) + eDataType = GDT_Float32; + else if( psImage->nBitsPerSample == 32 ) + eDataType = GDT_UInt32; + else if( psImage->nBitsPerSample == 64 + && EQUAL(psImage->szPVType,"R") ) + eDataType = GDT_Float64; + else + { + eDataType = GDT_Byte; + CPLError( CE_Warning, CPLE_AppDefined, + "Unsupported combination of PVTYPE(%s) and NBPP(%d).", + psImage->szPVType, psImage->nBitsPerSample ); + } + +/* -------------------------------------------------------------------- */ +/* Work out block size. If the image is all one big block we */ +/* handle via the scanline access API. */ +/* -------------------------------------------------------------------- */ + if( psImage->nBlocksPerRow == 1 + && psImage->nBlocksPerColumn == 1 + && EQUAL(psImage->szIC,"NC") ) + { + nBlockXSize = psImage->nBlockWidth; + nBlockYSize = 1; + } + else + { + nBlockXSize = psImage->nBlockWidth; + nBlockYSize = psImage->nBlockHeight; + } + +/* -------------------------------------------------------------------- */ +/* Do we have a color table? */ +/* -------------------------------------------------------------------- */ + poColorTable = NULL; + + if( psBandInfo->nSignificantLUTEntries > 0 ) + { + int iColor; + + poColorTable = new GDALColorTable(); + + for( iColor = 0; iColor < psBandInfo->nSignificantLUTEntries; iColor++) + { + GDALColorEntry sEntry; + + sEntry.c1 = psBandInfo->pabyLUT[ 0 + iColor]; + sEntry.c2 = psBandInfo->pabyLUT[256 + iColor]; + sEntry.c3 = psBandInfo->pabyLUT[512 + iColor]; + sEntry.c4 = 255; + + poColorTable->SetColorEntry( iColor, &sEntry ); + } + } +} + +/************************************************************************/ +/* ~NITFRasterBand() */ +/************************************************************************/ + +NITFRasterBand::~NITFRasterBand() + +{ + if( poColorTable != NULL ) + delete poColorTable; +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr NITFRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + int nBlockResult; + +/* -------------------------------------------------------------------- */ +/* Read the line/block */ +/* -------------------------------------------------------------------- */ + if( nBlockYSize == 1 ) + { + nBlockResult = + NITFReadImageLine(psImage, nBlockYOff, nBand, pImage); + } + else + { + nBlockResult = + NITFReadImageBlock(psImage, nBlockXOff, nBlockYOff, nBand, pImage); + } + + if( nBlockResult == BLKREAD_OK ) + return CE_None; + else if( nBlockResult == BLKREAD_FAIL ) + return CE_Failure; + else /* nBlockResult == BLKREAD_NULL */ + { + if( psImage->bNoDataSet ) + memset( pImage, psImage->nNoDataValue, + psImage->nWordSize*psImage->nBlockWidth*psImage->nBlockHeight); + else + memset( pImage, 0, + psImage->nWordSize*psImage->nBlockWidth*psImage->nBlockHeight); + + return CE_None; + } +} + +/************************************************************************/ +/* IWriteBlock() */ +/************************************************************************/ + +CPLErr NITFRasterBand::IWriteBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + int nBlockResult; + +/* -------------------------------------------------------------------- */ +/* Write the line/block */ +/* -------------------------------------------------------------------- */ + if( nBlockYSize == 1 ) + { + nBlockResult = + NITFWriteImageLine(psImage, nBlockYOff, nBand, pImage); + } + else + { + nBlockResult = + NITFWriteImageBlock(psImage, nBlockXOff, nBlockYOff, nBand,pImage); + } + + if( nBlockResult == BLKREAD_OK ) + return CE_None; + else + return CE_Failure; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double NITFRasterBand::GetNoDataValue( int *pbSuccess ) + +{ + if( pbSuccess != NULL ) + *pbSuccess = psImage->bNoDataSet; + + if( psImage->bNoDataSet ) + return psImage->nNoDataValue; + else + return -1e10; +} + +/************************************************************************/ +/* GetColorInterpretation() */ +/************************************************************************/ + +GDALColorInterp NITFRasterBand::GetColorInterpretation() + +{ + NITFBandInfo *psBandInfo = psImage->pasBandInfo + nBand - 1; + + if( poColorTable != NULL ) + return GCI_PaletteIndex; + + if( EQUAL(psBandInfo->szIREPBAND,"R") ) + return GCI_RedBand; + if( EQUAL(psBandInfo->szIREPBAND,"G") ) + return GCI_GreenBand; + if( EQUAL(psBandInfo->szIREPBAND,"B") ) + return GCI_BlueBand; + if( EQUAL(psBandInfo->szIREPBAND,"M") ) + return GCI_GrayIndex; + if( EQUAL(psBandInfo->szIREPBAND,"Y") ) + return GCI_YCbCr_YBand; + if( EQUAL(psBandInfo->szIREPBAND,"Cb") ) + return GCI_YCbCr_CbBand; + if( EQUAL(psBandInfo->szIREPBAND,"Cr") ) + return GCI_YCbCr_CrBand; + + return GCI_Undefined; +} + +/************************************************************************/ +/* NITFSetColorInterpretation() */ +/************************************************************************/ + +static CPLErr NITFSetColorInterpretation( NITFImage *psImage, + int nBand, + GDALColorInterp eInterp ) + +{ + NITFBandInfo *psBandInfo = psImage->pasBandInfo + nBand - 1; + const char *pszREP = NULL; + GUInt32 nOffset; + + if( eInterp == GCI_RedBand ) + pszREP = "R"; + else if( eInterp == GCI_GreenBand ) + pszREP = "G"; + else if( eInterp == GCI_BlueBand ) + pszREP = "B"; + else if( eInterp == GCI_GrayIndex ) + pszREP = "M"; + else if( eInterp == GCI_YCbCr_YBand ) + pszREP = "Y"; + else if( eInterp == GCI_YCbCr_CbBand ) + pszREP = "Cb"; + else if( eInterp == GCI_YCbCr_CrBand ) + pszREP = "Cr"; + else if( eInterp == GCI_Undefined ) + return CE_None; + + if( pszREP == NULL ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Requested color interpretation (%s) not supported in NITF.", + GDALGetColorInterpretationName( eInterp ) ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Where does this go in the file? */ +/* -------------------------------------------------------------------- */ + strcpy( psBandInfo->szIREPBAND, pszREP ); + nOffset = NITFIHFieldOffset( psImage, "IREPBAND" ); + + if( nOffset != 0 ) + nOffset += (nBand - 1) * 13; + +/* -------------------------------------------------------------------- */ +/* write it (space padded). */ +/* -------------------------------------------------------------------- */ + char szPadded[4]; + strcpy( szPadded, pszREP ); + strcat( szPadded, " " ); + + if( nOffset != 0 ) + { + if( VSIFSeekL( psImage->psFile->fp, nOffset, SEEK_SET ) != 0 + || VSIFWriteL( (void *) szPadded, 1, 2, psImage->psFile->fp ) != 2 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "IO failure writing new IREPBAND value to NITF file." ); + return CE_Failure; + } + } + + return CE_None; +} + +/************************************************************************/ +/* SetColorInterpretation() */ +/************************************************************************/ + +CPLErr NITFRasterBand::SetColorInterpretation( GDALColorInterp eInterp ) + +{ + return NITFSetColorInterpretation( psImage, nBand, eInterp ); +} + +/************************************************************************/ +/* GetColorTable() */ +/************************************************************************/ + +GDALColorTable *NITFRasterBand::GetColorTable() + +{ + return poColorTable; +} + +/************************************************************************/ +/* SetColorTable() */ +/************************************************************************/ + +CPLErr NITFRasterBand::SetColorTable( GDALColorTable *poNewCT ) + +{ + GByte abyNITFLUT[768]; + int i; + int nCount = MIN(256,poNewCT->GetColorEntryCount()); + + memset( abyNITFLUT, 0, 768 ); + for( i = 0; i < nCount; i++ ) + { + GDALColorEntry sEntry; + + poNewCT->GetColorEntryAsRGB( i, &sEntry ); + abyNITFLUT[i ] = (GByte) sEntry.c1; + abyNITFLUT[i+256] = (GByte) sEntry.c2; + abyNITFLUT[i+512] = (GByte) sEntry.c3; + } + + if( NITFWriteLUT( psImage, nBand, nCount, abyNITFLUT ) ) + return CE_None; + else + return CE_Failure; +} + +/************************************************************************/ +/* ==================================================================== */ +/* NITFDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* NITFDataset() */ +/************************************************************************/ + +NITFDataset::NITFDataset() + +{ + psFile = NULL; + psImage = NULL; + bGotGeoTransform = FALSE; + pszProjection = CPLStrdup(""); + poJ2KDataset = NULL; + bJP2Writing = FALSE; + + nGCPCount = 0; + pasGCPList = NULL; + pszGCPProjection = NULL; + + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; +} + +/************************************************************************/ +/* ~NITFDataset() */ +/************************************************************************/ + +NITFDataset::~NITFDataset() + +{ + FlushCache(); + +/* -------------------------------------------------------------------- */ +/* If we have been writing to a JPEG2000 file, check if the */ +/* color interpretations were set. If so, apply the settings */ +/* to the NITF file. */ +/* -------------------------------------------------------------------- */ + if( poJ2KDataset != NULL && bJP2Writing ) + { + int i; + + for( i = 0; i < nBands && papoBands != NULL; i++ ) + { + if( papoBands[i]->GetColorInterpretation() != GCI_Undefined ) + NITFSetColorInterpretation( psImage, i+1, + papoBands[i]->GetColorInterpretation() ); + } + } + +/* -------------------------------------------------------------------- */ +/* Close the underlying NITF file. */ +/* -------------------------------------------------------------------- */ + int nImageStart = -1; + if( psFile != NULL ) + { + nImageStart = psFile->pasSegmentInfo[0].nSegmentStart; + + NITFClose( psFile ); + psFile = NULL; + } + +/* -------------------------------------------------------------------- */ +/* Free datastructures. */ +/* -------------------------------------------------------------------- */ + CPLFree( pszProjection ); + + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + +/* -------------------------------------------------------------------- */ +/* If we have a jpeg2000 output file, make sure it gets closed */ +/* and flushed out. */ +/* -------------------------------------------------------------------- */ + if( poJ2KDataset != NULL ) + { + int i; + + GDALClose( (GDALDatasetH) poJ2KDataset ); + + // the bands are really jpeg2000 bands ... remove them + // from the NITF list so they won't get destroyed twice. + for( i = 0; i < nBands && papoBands != NULL; i++ ) + papoBands[i] = NULL; + } + +/* -------------------------------------------------------------------- */ +/* Update file length, and COMRAT for JPEG2000 files we are */ +/* writing to. */ +/* -------------------------------------------------------------------- */ + if( bJP2Writing ) + { + GIntBig nPixelCount = nRasterXSize * ((GIntBig) nRasterYSize) * + nBands; + + NITFPatchImageLength( GetDescription(), nImageStart, nPixelCount ); + } + +} + +/************************************************************************/ +/* FlushCache() */ +/************************************************************************/ + +void NITFDataset::FlushCache() + +{ + if( poJ2KDataset != NULL && bJP2Writing) + poJ2KDataset->FlushCache(); + + GDALPamDataset::FlushCache(); +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *NITFDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int nIMIndex = -1; + const char *pszFilename = poOpenInfo->pszFilename; + +/* -------------------------------------------------------------------- */ +/* Select a specific subdataset. */ +/* -------------------------------------------------------------------- */ + if( EQUALN(pszFilename, "NITF_IM:",8) ) + { + pszFilename += 8; + nIMIndex = atoi(pszFilename); + + while( *pszFilename != '\0' && *pszFilename != ':' ) + pszFilename++; + + if( *pszFilename == ':' ) + pszFilename++; + } + +/* -------------------------------------------------------------------- */ +/* First we check to see if the file has the expected header */ +/* bytes. */ +/* -------------------------------------------------------------------- */ + else + { + if( poOpenInfo->nHeaderBytes < 4 ) + return NULL; + + if( !EQUALN((char *) poOpenInfo->pabyHeader,"NITF",4) + && !EQUALN((char *) poOpenInfo->pabyHeader,"NSIF",4) + && !EQUALN((char *) poOpenInfo->pabyHeader,"NITF",4) ) + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Open the file with library. */ +/* -------------------------------------------------------------------- */ + NITFFile *psFile; + + psFile = NITFOpen( pszFilename, poOpenInfo->eAccess == GA_Update ); + if( psFile == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Is there an image to operate on? */ +/* -------------------------------------------------------------------- */ + int iSegment, nThisIM = 0; + NITFImage *psImage = NULL; + + for( iSegment = 0; iSegment < psFile->nSegmentCount; iSegment++ ) + { + if( EQUAL(psFile->pasSegmentInfo[iSegment].szSegmentType,"IM") + && (nThisIM++ == nIMIndex || nIMIndex == -1) ) + { + psImage = NITFImageAccess( psFile, iSegment ); + if( psImage == NULL ) + { + NITFClose( psFile ); + return NULL; + } + break; + } + } + +/* -------------------------------------------------------------------- */ +/* If no image segments found report this to the user. */ +/* -------------------------------------------------------------------- */ + if( psImage == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "The file %s appears to be an NITF file, but no image\n" + "blocks were found on it. GDAL cannot utilize non-image\n" + "NITF files.", + poOpenInfo->pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + NITFDataset *poDS; + + poDS = new NITFDataset(); + + poDS->psFile = psFile; + poDS->psImage = psImage; + poDS->eAccess = poOpenInfo->eAccess; + + poDS->nRasterXSize = psImage->nCols; + poDS->nRasterYSize = psImage->nRows; + +/* -------------------------------------------------------------------- */ +/* If the image is JPEG2000 (C8) compressed, we will need to */ +/* open the image data as a JPEG2000 dataset. */ +/* -------------------------------------------------------------------- */ + int nUsableBands = psImage->nBands; + int iBand; + + if( EQUAL(psImage->szIC,"C8") ) + { + char *pszDSName = CPLStrdup( + CPLSPrintf( "J2K_SUBFILE:%d,%d,%s", + psFile->pasSegmentInfo[iSegment].nSegmentStart, + psFile->pasSegmentInfo[iSegment].nSegmentSize, + pszFilename ) ); + + if( poWritableJ2KDataset != NULL ) + { + poDS->poJ2KDataset = poWritableJ2KDataset; + poDS->bJP2Writing = TRUE; + poWritableJ2KDataset = NULL; + } + else + { + poDS->poJ2KDataset = (GDALDataset *) + GDALOpen( pszDSName, GA_ReadOnly ); + CPLFree( pszDSName ); + } + + if( poDS->poJ2KDataset == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to open JPEG2000 image within NITF file.\n" + "Is the JP2KAK driver available?" ); + delete poDS; + return NULL; + } + + if( poDS->poJ2KDataset->GetRasterCount() < nUsableBands ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "JPEG2000 data stream has less useful bands than expected, likely\n" + "because some channels have differing resolutions." ); + + nUsableBands = poDS->poJ2KDataset->GetRasterCount(); + } + + // Force NITF derived color space info + for( iBand = 0; iBand < nUsableBands; iBand++ ) + { + NITFBandInfo *psBandInfo = psImage->pasBandInfo + iBand; + GDALRasterBand *poBand=poDS->poJ2KDataset->GetRasterBand(iBand+1); + + if( EQUAL(psBandInfo->szIREPBAND,"R") ) + poBand->SetColorInterpretation( GCI_RedBand ); + if( EQUAL(psBandInfo->szIREPBAND,"G") ) + poBand->SetColorInterpretation( GCI_GreenBand ); + if( EQUAL(psBandInfo->szIREPBAND,"B") ) + poBand->SetColorInterpretation( GCI_BlueBand ); + if( EQUAL(psBandInfo->szIREPBAND,"M") ) + poBand->SetColorInterpretation( GCI_GrayIndex ); + if( EQUAL(psBandInfo->szIREPBAND,"Y") ) + poBand->SetColorInterpretation( GCI_YCbCr_YBand ); + if( EQUAL(psBandInfo->szIREPBAND,"Cb") ) + poBand->SetColorInterpretation( GCI_YCbCr_CbBand ); + if( EQUAL(psBandInfo->szIREPBAND,"Cr") ) + poBand->SetColorInterpretation( GCI_YCbCr_CrBand ); + } + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + for( iBand = 0; iBand < nUsableBands; iBand++ ) + { + if( poDS->poJ2KDataset == NULL ) + poDS->SetBand( iBand+1, new NITFRasterBand( poDS, iBand+1 ) ); + else + { + poDS->SetBand( iBand+1, + poDS->poJ2KDataset->GetRasterBand(iBand+1) ); + } + } + +/* -------------------------------------------------------------------- */ +/* Process the projection from the ICORDS. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference oSRSWork; + + if( psImage->chICORDS == 'G' ) + { + CPLFree( poDS->pszProjection ); + poDS->pszProjection = NULL; + + oSRSWork.SetWellKnownGeogCS( "WGS84" ); + oSRSWork.exportToWkt( &(poDS->pszProjection) ); + } + else if( psImage->chICORDS == 'C' ) + { + CPLFree( poDS->pszProjection ); + poDS->pszProjection = NULL; + + oSRSWork.SetWellKnownGeogCS( "WGS84" ); + oSRSWork.exportToWkt( &(poDS->pszProjection) ); + + /* convert latitudes from geocentric to geodetic form. */ + + psImage->dfULY = + NITF_WGS84_Geocentric_Latitude_To_Geodetic_Latitude( + psImage->dfULY ); + psImage->dfLLY = + NITF_WGS84_Geocentric_Latitude_To_Geodetic_Latitude( + psImage->dfLLY ); + psImage->dfURY = + NITF_WGS84_Geocentric_Latitude_To_Geodetic_Latitude( + psImage->dfURY ); + psImage->dfLRY = + NITF_WGS84_Geocentric_Latitude_To_Geodetic_Latitude( + psImage->dfLRY ); + } + else if( psImage->chICORDS == 'S' || psImage->chICORDS == 'N' ) + { + CPLFree( poDS->pszProjection ); + poDS->pszProjection = NULL; + + oSRSWork.SetUTM( psImage->nZone, psImage->chICORDS == 'N' ); + oSRSWork.SetWellKnownGeogCS( "WGS84" ); + oSRSWork.exportToWkt( &(poDS->pszProjection) ); + } + else if( psImage->chICORDS == 'U' && psImage->nZone != 0 ) + { + CPLFree( poDS->pszProjection ); + poDS->pszProjection = NULL; + + oSRSWork.SetUTM( ABS(psImage->nZone), psImage->nZone > 0 ); + oSRSWork.SetWellKnownGeogCS( "WGS84" ); + oSRSWork.exportToWkt( &(poDS->pszProjection) ); + } + + +/* -------------------------------------------------------------------- */ +/* Try looking for a .nfw file. */ +/* -------------------------------------------------------------------- */ + if( GDALReadWorldFile( pszFilename, "nfw", + poDS->adfGeoTransform ) ) + { + const char *pszHDR; + FILE *fpHDR; + char **papszLines; + int isNorth; + int zone; + + poDS->bGotGeoTransform = TRUE; + + /* If nfw found, try looking for a header with projection info */ + /* in space imaging style format */ + pszHDR = CPLResetExtension( pszFilename, "hdr" ); + + fpHDR = VSIFOpen( pszHDR, "rt" ); + +#ifndef WIN32 + if( fpHDR == NULL ) + { + pszHDR = CPLResetExtension( pszFilename, "HDR" ); + fpHDR = VSIFOpen( pszHDR, "rt" ); + } +#endif + + if( fpHDR != NULL ) + { + VSIFClose( fpHDR ); + papszLines=CSLLoad(pszHDR); + if (CSLCount(papszLines) == 16) + { + + if (psImage->chICORDS == 'N') + isNorth=1; + else if (psImage->chICORDS =='S') + isNorth=0; + else + { + if (psImage->dfLLY+psImage->dfLRY+psImage->dfULY+psImage->dfURY < 0) + isNorth=0; + else + isNorth=1; + } + if( (EQUALN(papszLines[7], + "Selected Projection: Universal Transverse Mercator",50)) && + (EQUALN(papszLines[8],"Zone: ",6)) && + (strlen(papszLines[8]) >= 7)) + { + CPLFree( poDS->pszProjection ); + poDS->pszProjection = NULL; + zone=atoi(&(papszLines[8][6])); + oSRSWork.SetUTM( zone, isNorth ); + oSRSWork.SetWellKnownGeogCS( "WGS84" ); + oSRSWork.exportToWkt( &(poDS->pszProjection) ); + } + else + { + /* Couldn't find associated projection info. + Go back to original file for geotransform. + */ + poDS->bGotGeoTransform = FALSE; + } + } + else + poDS->bGotGeoTransform = FALSE; + CSLDestroy(papszLines); + } + else + poDS->bGotGeoTransform = FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Do we have IGEOLO data that can be treated as a */ +/* geotransform? Our approach should support images in an */ +/* affine rotated frame of reference. */ +/* -------------------------------------------------------------------- */ + int nGCPCount = 0; + GDAL_GCP *psGCPs = NULL; + + if( ( poDS->bGotGeoTransform == FALSE ) && ( psImage->chICORDS != ' ' ) ) + { + nGCPCount = 4; + + psGCPs = (GDAL_GCP *) CPLMalloc(sizeof(GDAL_GCP) * nGCPCount); + GDALInitGCPs( nGCPCount, psGCPs ); + + psGCPs[0].dfGCPPixel = 0.0; + psGCPs[0].dfGCPLine = 0.0; + psGCPs[0].dfGCPX = psImage->dfULX; + psGCPs[0].dfGCPY = psImage->dfULY; + + psGCPs[1].dfGCPPixel = poDS->nRasterXSize; + psGCPs[1].dfGCPLine = 0.0; + psGCPs[1].dfGCPX = psImage->dfURX; + psGCPs[1].dfGCPY = psImage->dfURY; + + psGCPs[2].dfGCPPixel = poDS->nRasterXSize; + psGCPs[2].dfGCPLine = poDS->nRasterYSize; + psGCPs[2].dfGCPX = psImage->dfLRX; + psGCPs[2].dfGCPY = psImage->dfLRY; + + psGCPs[3].dfGCPPixel = 0.0; + psGCPs[3].dfGCPLine = poDS->nRasterYSize; + psGCPs[3].dfGCPX = psImage->dfLLX; + psGCPs[3].dfGCPY = psImage->dfLLY; + } + +/* -------------------------------------------------------------------- */ +/* Convert the GCPs into a geotransform definition, if possible. */ +/* -------------------------------------------------------------------- */ + if( ( poDS->bGotGeoTransform == FALSE ) && nGCPCount > 0 && + GDALGCPsToGeoTransform( nGCPCount, psGCPs, + poDS->adfGeoTransform, TRUE ) ) + { + poDS->bGotGeoTransform = TRUE; + } + +/* -------------------------------------------------------------------- */ +/* If we have IGEOLO that isn't north up, return it as GCPs. */ +/* -------------------------------------------------------------------- */ + else if( (psImage->dfULX != 0 || psImage->dfURX != 0 + || psImage->dfLRX != 0 || psImage->dfLLX != 0) + && psImage->chICORDS != ' ' && + ( poDS->bGotGeoTransform == FALSE ) ) + { + CPLDebug( "GDAL", + "NITFDataset::Open() wasn't able to derive a first order\n" + "geotransform. It will be returned as GCPs."); + + poDS->nGCPCount = 4; + poDS->pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP), + poDS->nGCPCount); + GDALInitGCPs( 4, poDS->pasGCPList ); + + poDS->pasGCPList[0].dfGCPX = psImage->dfULX; + poDS->pasGCPList[0].dfGCPY = psImage->dfULY; + poDS->pasGCPList[0].dfGCPPixel = 0; + poDS->pasGCPList[0].dfGCPLine = 0; + CPLFree( poDS->pasGCPList[0].pszId ); + poDS->pasGCPList[0].pszId = CPLStrdup( "UpperLeft" ); + + poDS->pasGCPList[1].dfGCPX = psImage->dfURX; + poDS->pasGCPList[1].dfGCPY = psImage->dfURY; + poDS->pasGCPList[1].dfGCPPixel = poDS->nRasterXSize; + poDS->pasGCPList[1].dfGCPLine = 0; + CPLFree( poDS->pasGCPList[1].pszId ); + poDS->pasGCPList[1].pszId = CPLStrdup( "UpperRight" ); + + poDS->pasGCPList[2].dfGCPX = psImage->dfLLX; + poDS->pasGCPList[2].dfGCPY = psImage->dfLLY; + poDS->pasGCPList[2].dfGCPPixel = 0; + poDS->pasGCPList[2].dfGCPLine = poDS->nRasterYSize; + CPLFree( poDS->pasGCPList[2].pszId ); + poDS->pasGCPList[2].pszId = CPLStrdup( "LowerLeft" ); + + poDS->pasGCPList[3].dfGCPX = psImage->dfLRX; + poDS->pasGCPList[3].dfGCPY = psImage->dfLRY; + poDS->pasGCPList[3].dfGCPPixel = poDS->nRasterXSize; + poDS->pasGCPList[3].dfGCPLine = poDS->nRasterYSize; + CPLFree( poDS->pasGCPList[3].pszId ); + poDS->pasGCPList[3].pszId = CPLStrdup( "LowerRight" ); + + poDS->pszGCPProjection = CPLStrdup( poDS->pszProjection ); + } + + // This cleans up the original copy of the GCPs used to test if + // this IGEOLO could be used for a geotransform. + if( nGCPCount > 0 ) + { + GDALDeinitGCPs( nGCPCount, psGCPs ); + CPLFree( psGCPs ); + } + +/* -------------------------------------------------------------------- */ +/* Do we have metadata. */ +/* -------------------------------------------------------------------- */ + char **papszMergedMD; + char **papszUSE00A_MD; + + // File and Image level metadata. + papszMergedMD = CSLDuplicate( poDS->psFile->papszMetadata ); + papszMergedMD = CSLInsertStrings( papszMergedMD, + CSLCount( papszMergedMD ), + psImage->papszMetadata ); + + // Comments. + if( psImage->pszComments != NULL && strlen(psImage->pszComments) != 0 ) + papszMergedMD = CSLSetNameValue( + papszMergedMD, "NITF_IMAGE_COMMENTS", psImage->pszComments ); + + // Compression code. + papszMergedMD = CSLSetNameValue( papszMergedMD, "NITF_IC", + psImage->szIC ); + + // IMODE + char szIMODE[2]; + szIMODE[0] = psImage->chIMODE; + szIMODE[1] = '\0'; + papszMergedMD = CSLSetNameValue( papszMergedMD, "NITF_IMODE", szIMODE ); + + // USE00A + papszUSE00A_MD = NITFReadUSE00A( psImage ); + if( papszUSE00A_MD != NULL ) + { + papszMergedMD = CSLInsertStrings( papszMergedMD, + CSLCount( papszUSE00A_MD ), + papszUSE00A_MD ); + CSLDestroy( papszUSE00A_MD ); + } + + papszUSE00A_MD = NITFReadSTDIDC( psImage ); + if( papszUSE00A_MD != NULL ) + { + papszMergedMD = CSLInsertStrings( papszMergedMD, + CSLCount( papszUSE00A_MD ), + papszUSE00A_MD ); + CSLDestroy( papszUSE00A_MD ); + } + + poDS->SetMetadata( papszMergedMD ); + CSLDestroy( papszMergedMD ); + +/* -------------------------------------------------------------------- */ +/* Image structure metadata. */ +/* -------------------------------------------------------------------- */ + if( psImage->szIC[1] == '1' ) + poDS->SetMetadataItem( "COMPRESSION", "BILEVEL", + "IMAGE_STRUCTURE" ); + else if( psImage->szIC[1] == '2' ) + poDS->SetMetadataItem( "COMPRESSION", "???", + "IMAGE_STRUCTURE" ); + else if( psImage->szIC[1] == '3' ) + poDS->SetMetadataItem( "COMPRESSION", "JPEG", + "IMAGE_STRUCTURE" ); + else if( psImage->szIC[1] == '4' ) + poDS->SetMetadataItem( "COMPRESSION", "VECTOR QUANTIZATION", + "IMAGE_STRUCTURE" ); + else if( psImage->szIC[1] == '5' ) + poDS->SetMetadataItem( "COMPRESSION", "LOSSLESS JPEG", + "IMAGE_STRUCTURE" ); + else if( psImage->szIC[1] == '8' ) + poDS->SetMetadataItem( "COMPRESSION", "JPEG2000", + "IMAGE_STRUCTURE" ); + +/* -------------------------------------------------------------------- */ +/* Do we have RPC info. */ +/* -------------------------------------------------------------------- */ + NITFRPC00BInfo sRPCInfo; + + if( NITFReadRPC00B( psImage, &sRPCInfo ) && sRPCInfo.SUCCESS ) + { + char szValue[1280]; + int i; + + sprintf( szValue, "%.16g", sRPCInfo.LINE_OFF ); + poDS->SetMetadataItem( "RPC_LINE_OFF", szValue ); + + sprintf( szValue, "%.16g", sRPCInfo.LINE_SCALE ); + poDS->SetMetadataItem( "RPC_LINE_SCALE", szValue ); + + sprintf( szValue, "%.16g", sRPCInfo.SAMP_OFF ); + poDS->SetMetadataItem( "RPC_SAMP_OFF", szValue ); + + sprintf( szValue, "%.16g", sRPCInfo.SAMP_SCALE ); + poDS->SetMetadataItem( "RPC_SAMP_SCALE", szValue ); + + sprintf( szValue, "%.16g", sRPCInfo.LONG_OFF ); + poDS->SetMetadataItem( "RPC_LONG_OFF", szValue ); + + sprintf( szValue, "%.16g", sRPCInfo.LONG_SCALE ); + poDS->SetMetadataItem( "RPC_LONG_SCALE", szValue ); + + sprintf( szValue, "%.16g", sRPCInfo.LAT_OFF ); + poDS->SetMetadataItem( "RPC_LAT_OFF", szValue ); + + sprintf( szValue, "%.16g", sRPCInfo.LAT_SCALE ); + poDS->SetMetadataItem( "RPC_LAT_SCALE", szValue ); + + sprintf( szValue, "%.16g", sRPCInfo.HEIGHT_OFF ); + poDS->SetMetadataItem( "RPC_HEIGHT_OFF", szValue ); + + sprintf( szValue, "%.16g", sRPCInfo.HEIGHT_SCALE ); + poDS->SetMetadataItem( "RPC_HEIGHT_SCALE", szValue ); + + szValue[0] = '\0'; + for( i = 0; i < 20; i++ ) + sprintf( szValue+strlen(szValue), "%.16g ", + sRPCInfo.LINE_NUM_COEFF[i] ); + poDS->SetMetadataItem( "RPC_LINE_NUM_COEFF", szValue ); + + szValue[0] = '\0'; + for( i = 0; i < 20; i++ ) + sprintf( szValue+strlen(szValue), "%.16g ", + sRPCInfo.LINE_DEN_COEFF[i] ); + poDS->SetMetadataItem( "RPC_LINE_DEN_COEFF", szValue ); + + szValue[0] = '\0'; + for( i = 0; i < 20; i++ ) + sprintf( szValue+strlen(szValue), "%.16g ", + sRPCInfo.SAMP_NUM_COEFF[i] ); + poDS->SetMetadataItem( "RPC_SAMP_NUM_COEFF", szValue ); + + szValue[0] = '\0'; + for( i = 0; i < 20; i++ ) + sprintf( szValue+strlen(szValue), "%.16g ", + sRPCInfo.SAMP_DEN_COEFF[i] ); + poDS->SetMetadataItem( "RPC_SAMP_DEN_COEFF", szValue ); + + sprintf( szValue, "%.16g", + sRPCInfo.LONG_OFF - ( sRPCInfo.LONG_SCALE / 2.0 ) ); + poDS->SetMetadataItem( "RPC_MIN_LONG", szValue ); + + sprintf( szValue, "%.16g", + sRPCInfo.LONG_OFF + ( sRPCInfo.LONG_SCALE / 2.0 ) ); + poDS->SetMetadataItem( "RPC_MAX_LONG", szValue ); + + sprintf( szValue, "%.16g", + sRPCInfo.LAT_OFF - ( sRPCInfo.LAT_SCALE / 2.0 ) ); + poDS->SetMetadataItem( "RPC_MIN_LAT", szValue ); + + sprintf( szValue, "%.16g", + sRPCInfo.LAT_OFF + ( sRPCInfo.LAT_SCALE / 2.0 ) ); + poDS->SetMetadataItem( "RPC_MAX_LAT", szValue ); + } + +/* -------------------------------------------------------------------- */ +/* Do we have Chip info? */ +/* -------------------------------------------------------------------- */ + NITFICHIPBInfo sChipInfo; + + if( NITFReadICHIPB( psImage, &sChipInfo ) && sChipInfo.XFRM_FLAG == 0 ) + { + char szValue[1280]; + + sprintf( szValue, "%.16g", sChipInfo.SCALE_FACTOR ); + poDS->SetMetadataItem( "ICHIP_SCALE_FACTOR", szValue ); + + sprintf( szValue, "%d", sChipInfo.ANAMORPH_CORR ); + poDS->SetMetadataItem( "ICHIP_ANAMORPH_CORR", szValue ); + + sprintf( szValue, "%d", sChipInfo.SCANBLK_NUM ); + poDS->SetMetadataItem( "ICHIP_SCANBLK_NUM", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.OP_ROW_11 ); + poDS->SetMetadataItem( "ICHIP_OP_ROW_11", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.OP_COL_11 ); + poDS->SetMetadataItem( "ICHIP_OP_COL_11", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.OP_ROW_12 ); + poDS->SetMetadataItem( "ICHIP_OP_ROW_12", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.OP_COL_12 ); + poDS->SetMetadataItem( "ICHIP_OP_COL_12", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.OP_ROW_21 ); + poDS->SetMetadataItem( "ICHIP_OP_ROW_21", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.OP_COL_21 ); + poDS->SetMetadataItem( "ICHIP_OP_COL_21", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.OP_ROW_22 ); + poDS->SetMetadataItem( "ICHIP_OP_ROW_22", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.OP_COL_22 ); + poDS->SetMetadataItem( "ICHIP_OP_COL_22", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.FI_ROW_11 ); + poDS->SetMetadataItem( "ICHIP_FI_ROW_11", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.FI_COL_11 ); + poDS->SetMetadataItem( "ICHIP_FI_COL_11", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.FI_ROW_12 ); + poDS->SetMetadataItem( "ICHIP_FI_ROW_12", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.FI_COL_12 ); + poDS->SetMetadataItem( "ICHIP_FI_COL_12", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.FI_ROW_21 ); + poDS->SetMetadataItem( "ICHIP_FI_ROW_21", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.FI_COL_21 ); + poDS->SetMetadataItem( "ICHIP_FI_COL_21", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.FI_ROW_22 ); + poDS->SetMetadataItem( "ICHIP_FI_ROW_22", szValue ); + + sprintf( szValue, "%.16g", sChipInfo.FI_COL_22 ); + poDS->SetMetadataItem( "ICHIP_FI_COL_22", szValue ); + + sprintf( szValue, "%d", sChipInfo.FI_ROW ); + poDS->SetMetadataItem( "ICHIP_FI_ROW", szValue ); + + sprintf( szValue, "%d", sChipInfo.FI_COL ); + poDS->SetMetadataItem( "ICHIP_FI_COL", szValue ); + + } + +/* -------------------------------------------------------------------- */ +/* If there are multiple image segments, and we are the zeroth, */ +/* then setup the subdataset metadata. */ +/* -------------------------------------------------------------------- */ + if( nIMIndex == -1 ) + { + char **papszSubdatasets = NULL; + int nIMCounter = 0; + + for( iSegment = 0; iSegment < psFile->nSegmentCount; iSegment++ ) + { + if( EQUAL(psFile->pasSegmentInfo[iSegment].szSegmentType,"IM") ) + { + CPLString oName; + CPLString oValue; + + oName.Printf( "SUBDATASET_%d_NAME", nIMCounter+1 ); + oValue.Printf( "NITF_IM:%d:%s", nIMCounter, pszFilename ); + papszSubdatasets = CSLSetNameValue( papszSubdatasets, + oName, oValue ); + + oName.Printf( "SUBDATASET_%d_DESC", nIMCounter+1 ); + oValue.Printf( "Image %d of %s", nIMCounter+1, pszFilename ); + papszSubdatasets = CSLSetNameValue( papszSubdatasets, + oName, oValue ); + + nIMCounter++; + } + } + + if( CSLCount(papszSubdatasets) > 2 ) + poDS->GDALMajorObject::SetMetadata( papszSubdatasets, "SUBDATASETS" ); + + CSLDestroy( papszSubdatasets ); + } + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* AdviseRead() */ +/************************************************************************/ + +CPLErr NITFDataset::AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize, + int nBufXSize, int nBufYSize, + GDALDataType eDT, + int nBandCount, int *panBandList, + char **papszOptions ) + +{ + if( poJ2KDataset == NULL ) + return GDALDataset::AdviseRead( nXOff, nYOff, nXSize, nYSize, + nBufXSize, nBufYSize, eDT, + nBandCount, panBandList, + papszOptions); + else + return poJ2KDataset->AdviseRead( nXOff, nYOff, nXSize, nYSize, + nBufXSize, nBufYSize, eDT, + nBandCount, panBandList, + papszOptions); +} + +/************************************************************************/ +/* IRasterIO() */ +/************************************************************************/ + +CPLErr NITFDataset::IRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int *panBandMap, + int nPixelSpace, int nLineSpace, int nBandSpace) + +{ + if( poJ2KDataset == NULL ) + return GDALDataset::IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize, + pData, nBufXSize, nBufYSize, eBufType, + nBandCount, panBandMap, + nPixelSpace, nLineSpace, nBandSpace ); + else + return poJ2KDataset->RasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize, + pData, nBufXSize, nBufYSize, eBufType, + nBandCount, panBandMap, + nPixelSpace, nLineSpace, nBandSpace ); +} + + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr NITFDataset::GetGeoTransform( double *padfGeoTransform ) + +{ + memcpy( padfGeoTransform, adfGeoTransform, sizeof(double) * 6 ); + + if( bGotGeoTransform ) + return CE_None; + else + return CE_Failure; +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr NITFDataset::SetGeoTransform( double *padfGeoTransform ) + +{ + double dfIGEOLOULX, dfIGEOLOULY, dfIGEOLOURX, dfIGEOLOURY, + dfIGEOLOLRX, dfIGEOLOLRY, dfIGEOLOLLX, dfIGEOLOLLY; + + + dfIGEOLOULX = padfGeoTransform[0] + 0.5 * padfGeoTransform[1] + + 0.5 * padfGeoTransform[2]; + dfIGEOLOULY = padfGeoTransform[3] + 0.5 * padfGeoTransform[4] + + 0.5 * padfGeoTransform[5]; + dfIGEOLOURX = dfIGEOLOULX + padfGeoTransform[1] * (nRasterXSize - 1); + dfIGEOLOURY = dfIGEOLOULY + padfGeoTransform[4] * (nRasterXSize - 1); + dfIGEOLOLRX = dfIGEOLOULX + padfGeoTransform[1] * (nRasterXSize - 1) + + padfGeoTransform[2] * (nRasterYSize - 1); + dfIGEOLOLRY = dfIGEOLOULY + padfGeoTransform[4] * (nRasterXSize - 1) + + padfGeoTransform[5] * (nRasterYSize - 1); + dfIGEOLOLLX = dfIGEOLOULX + padfGeoTransform[2] * (nRasterYSize - 1); + dfIGEOLOLLY = dfIGEOLOULY + padfGeoTransform[5] * (nRasterYSize - 1); + + if( NITFWriteIGEOLO( psImage, psImage->chICORDS, + psImage->nZone, + dfIGEOLOULX, dfIGEOLOULY, dfIGEOLOURX, dfIGEOLOURY, + dfIGEOLOLRX, dfIGEOLOLRY, dfIGEOLOLLX, dfIGEOLOLLY ) ) + return CE_None; + else + return CE_Failure; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *NITFDataset::GetProjectionRef() + +{ + if( bGotGeoTransform ) + return pszProjection; + else + return ""; +} + +/************************************************************************/ +/* GetGCPCount() */ +/************************************************************************/ + +int NITFDataset::GetGCPCount() + +{ + return nGCPCount; +} + +/************************************************************************/ +/* GetGCPProjection() */ +/************************************************************************/ + +const char *NITFDataset::GetGCPProjection() + +{ + if( nGCPCount > 0 && pszGCPProjection != NULL ) + return pszGCPProjection; + else + return ""; +} + +/************************************************************************/ +/* GetGCP() */ +/************************************************************************/ + +const GDAL_GCP *NITFDataset::GetGCPs() + +{ + return pasGCPList; +} + +/************************************************************************/ +/* GDALToNITFDataType() */ +/************************************************************************/ + +static const char *GDALToNITFDataType( GDALDataType eType ) + +{ + const char *pszPVType; + + switch( eType ) + { + case GDT_Byte: + case GDT_UInt16: + case GDT_UInt32: + pszPVType = "INT"; + break; + + case GDT_Int16: + case GDT_Int32: + pszPVType = "SI"; + break; + + case GDT_Float32: + case GDT_Float64: + pszPVType = "R"; + break; + + case GDT_CInt16: + case GDT_CInt32: + CPLError( CE_Failure, CPLE_AppDefined, + "NITF format does not support complex integer data." ); + return NULL; + + case GDT_CFloat32: + case GDT_CFloat64: + pszPVType = "C"; + break; + + default: + CPLError( CE_Failure, CPLE_AppDefined, + "Unsupported raster pixel type (%d).", + (int) eType ); + return NULL; + } + + return pszPVType; +} + +/************************************************************************/ +/* NITFJP2Options() */ +/* */ +/* Prepare JP2-in-NITF creation options based in part of the */ +/* NITF creation options. */ +/************************************************************************/ + +static char **NITFJP2Options( char **papszOptions ) + +{ + int i; + static char *apszOptions[] = { + "PROFILE=NPJE", + "CODESTREAM_ONLY=TRUE", + NULL, + NULL }; + + apszOptions[2] = NULL; + for( i = 0; papszOptions != NULL && papszOptions[i] != NULL; i++ ) + { + if( EQUALN(papszOptions[i],"PROFILE=",8) ) + apszOptions[0] = papszOptions[i]; + if( EQUALN(papszOptions[i],"TARGET=",7) ) + apszOptions[2] = papszOptions[i]; + } + + return apszOptions; +} + +/************************************************************************/ +/* NITFDatasetCreate() */ +/************************************************************************/ + +static GDALDataset * +NITFDatasetCreate( const char *pszFilename, int nXSize, int nYSize, int nBands, + GDALDataType eType, char **papszOptions ) + +{ + const char *pszPVType = GDALToNITFDataType( eType ); + const char *pszIC = CSLFetchNameValue( papszOptions, "IC" ); + + if( pszPVType == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* We disallow any IC value except NC when creating this way. */ +/* -------------------------------------------------------------------- */ + GDALDriver *poJ2KDriver = NULL; + + if( pszIC != NULL && EQUAL(pszIC,"C8") ) + { + int bHasCreate = FALSE; + + poJ2KDriver = GetGDALDriverManager()->GetDriverByName( "JP2ECW" ); + if( poJ2KDriver != NULL ) + bHasCreate = poJ2KDriver->GetMetadataItem( GDAL_DCAP_CREATE, + NULL ) != NULL; + if( !bHasCreate ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to create JPEG2000 encoded NITF files. The\n" + "JP2ECW driver is unavailable, or missing Create support." ); + return NULL; + } + } + + else if( pszIC != NULL && !EQUAL(pszIC,"NC") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unsupported compression (IC=%s) used in direct\n" + "NITF File creation", + pszIC ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create the file. */ +/* -------------------------------------------------------------------- */ + + if( !NITFCreate( pszFilename, nXSize, nYSize, nBands, + GDALGetDataTypeSize( eType ), pszPVType, + papszOptions ) ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Various special hacks related to JPEG2000 encoded files. */ +/* -------------------------------------------------------------------- */ + if( poJ2KDriver ) + { + NITFFile *psFile = NITFOpen( pszFilename, TRUE ); + int nImageOffset = psFile->pasSegmentInfo[0].nSegmentStart; + + char *pszDSName = CPLStrdup( + CPLSPrintf( "J2K_SUBFILE:%d,%d,%s", nImageOffset, -1, + pszFilename ) ); + + NITFClose( psFile ); + + poWritableJ2KDataset = + poJ2KDriver->Create( pszDSName, nXSize, nYSize, nBands, eType, + NITFJP2Options( papszOptions ) ); + CPLFree( pszDSName ); + + if( poWritableJ2KDataset == NULL ) + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Open the dataset in update mode. */ +/* -------------------------------------------------------------------- */ + return (GDALDataset *) GDALOpen( pszFilename, GA_Update ); +} + +/************************************************************************/ +/* NITFCreateCopy() */ +/************************************************************************/ + +GDALDataset * +NITFDataset::NITFCreateCopy( + const char *pszFilename, GDALDataset *poSrcDS, + int bStrict, char **papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ + GDALDataType eType; + GDALRasterBand *poBand1 = poSrcDS->GetRasterBand(1); + char **papszFullOptions = CSLDuplicate( papszOptions ); + int bJPEG2000 = FALSE; + NITFDataset *poDstDS = NULL; + GDALDriver *poJ2KDriver = NULL; + + if( poBand1 == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* We disallow any IC value except NC when creating this way. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue( papszOptions, "IC" ) != NULL ) + { + if( EQUAL(CSLFetchNameValue( papszOptions, "IC" ),"NC") ) + /* ok */; + else if( EQUAL(CSLFetchNameValue( papszOptions, "IC" ),"C8") ) + { + poJ2KDriver = + GetGDALDriverManager()->GetDriverByName( "JP2ECW" ); + if( poJ2KDriver == NULL ) + { + CPLError( + CE_Failure, CPLE_AppDefined, + "Unable to write JPEG2000 compressed NITF file.\n" + "No 'subfile' JPEG2000 write supporting drivers are\n" + "configured." ); + return NULL; + } + bJPEG2000 = TRUE; + } + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Only IC=NC (uncompressed) and IC=C8 (JPEG2000) allowed\n" + "with NITF CreateCopy method." ); + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Get the data type. Complex integers isn't supported by */ +/* NITF, so map that to complex float if we aren't in strict */ +/* mode. */ +/* -------------------------------------------------------------------- */ + eType = poBand1->GetRasterDataType(); + if( !bStrict && (eType == GDT_CInt16 || eType == GDT_CInt32) ) + eType = GDT_CFloat32; + +/* -------------------------------------------------------------------- */ +/* Set if we can set IREP. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue(papszFullOptions,"IREP") == NULL ) + { + if( poSrcDS->GetRasterCount() == 3 && eType == GDT_Byte ) + papszFullOptions = + CSLSetNameValue( papszFullOptions, "IREP", "RGB" ); + + else if( poSrcDS->GetRasterCount() == 1 && eType == GDT_Byte + && poBand1->GetColorTable() != NULL ) + { + papszFullOptions = + CSLSetNameValue( papszFullOptions, "IREP", "RGB/LUT" ); + papszFullOptions = + CSLSetNameValue( papszFullOptions, "LUT_SIZE", + CPLSPrintf("%d", + poBand1->GetColorTable()->GetColorEntryCount()) ); + } + else if( GDALDataTypeIsComplex(eType) ) + papszFullOptions = + CSLSetNameValue( papszFullOptions, "IREP", "NODISPLY" ); + + else + papszFullOptions = + CSLSetNameValue( papszFullOptions, "IREP", "MONO" ); + } + +/* -------------------------------------------------------------------- */ +/* Do we have lat/long georeferencing information? */ +/* -------------------------------------------------------------------- */ + double adfGeoTransform[6]; + int bWriteGeoTransform = FALSE; + int bNorth, nZone = 0; + OGRSpatialReference oSRS; + char *pszWKT = (char *) poSrcDS->GetProjectionRef(); + + if( pszWKT != NULL ) + oSRS.importFromWkt( &pszWKT ); + + // For now we write all geographic coordinate systems whether WGS84 or not. + // But really NITF is always WGS84 and we ought to reflect that. + if( oSRS.IsGeographic() && oSRS.GetPrimeMeridian() == 0.0 + && poSrcDS->GetGeoTransform( adfGeoTransform ) == CE_None ) + { + papszFullOptions = + CSLSetNameValue( papszFullOptions, "ICORDS", "G" ); + bWriteGeoTransform = TRUE; + } + + else if( oSRS.GetUTMZone( &bNorth ) > 0 + && poSrcDS->GetGeoTransform( adfGeoTransform ) == CE_None ) + { + if( bNorth ) + papszFullOptions = + CSLSetNameValue( papszFullOptions, "ICORDS", "N" ); + else + papszFullOptions = + CSLSetNameValue( papszFullOptions, "ICORDS", "S" ); + + nZone = oSRS.GetUTMZone( NULL ); + bWriteGeoTransform = TRUE; + } + +/* -------------------------------------------------------------------- */ +/* Create the output file. */ +/* -------------------------------------------------------------------- */ + int nXSize = poSrcDS->GetRasterXSize(); + int nYSize = poSrcDS->GetRasterYSize(); + const char *pszPVType = GDALToNITFDataType( eType ); + + if( pszPVType == NULL ) + return NULL; + + NITFCreate( pszFilename, nXSize, nYSize, poSrcDS->GetRasterCount(), + GDALGetDataTypeSize( eType ), pszPVType, + papszFullOptions ); + + CSLDestroy( papszFullOptions ); + +/* ==================================================================== */ +/* Loop copying bands to an uncompressed file. */ +/* ==================================================================== */ + if( !bJPEG2000 ) + { + poDstDS = (NITFDataset *) GDALOpen( pszFilename, GA_Update ); + if( poDstDS == NULL ) + return NULL; + + for( int iBand = 0; iBand < poSrcDS->GetRasterCount(); iBand++ ) + { + GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( iBand+1 ); + GDALRasterBand *poDstBand = poDstDS->GetRasterBand( iBand+1 ); + +/* -------------------------------------------------------------------- */ +/* Do we need to copy a colortable or other metadata? */ +/* -------------------------------------------------------------------- */ + GDALColorTable *poCT; + + poCT = poSrcBand->GetColorTable(); + if( poCT != NULL ) + poDstBand->SetColorTable( poCT ); + +/* -------------------------------------------------------------------- */ +/* Copy image data. */ +/* -------------------------------------------------------------------- */ + void *pData; + CPLErr eErr; + + pData = CPLMalloc(nXSize * GDALGetDataTypeSize(eType) / 8); + + for( int iLine = 0; iLine < nYSize; iLine++ ) + { + eErr = poSrcBand->RasterIO( GF_Read, 0, iLine, nXSize, 1, + pData, nXSize, 1, eType, 0, 0 ); + if( eErr != CE_None ) + { + return NULL; + } + + eErr = poDstBand->RasterIO( GF_Write, 0, iLine, nXSize, 1, + pData, nXSize, 1, eType, 0, 0 ); + + if( eErr != CE_None ) + { + return NULL; + } + + if( !pfnProgress( (iBand + (iLine+1) / (double) nYSize) + / (double) poSrcDS->GetRasterCount(), + NULL, pProgressData ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + delete poDstDS; + return NULL; + } + } + + CPLFree( pData ); + } + } + +/* -------------------------------------------------------------------- */ +/* JPEG2000 case. We need to write the data through a J2K */ +/* driver in pixel interleaved form. */ +/* -------------------------------------------------------------------- */ + else if( bJPEG2000 ) + { + NITFFile *psFile = NITFOpen( pszFilename, TRUE ); + GDALDataset *poJ2KDataset = NULL; + int nImageOffset = psFile->pasSegmentInfo[0].nSegmentStart; + + char *pszDSName = CPLStrdup( + CPLSPrintf( "J2K_SUBFILE:%d,%d,%s", nImageOffset, -1, + pszFilename ) ); + + NITFClose( psFile ); + + poJ2KDataset = + poJ2KDriver->CreateCopy( pszDSName, poSrcDS, FALSE, + NITFJP2Options(papszOptions), + pfnProgress, pProgressData ); + CPLFree( pszDSName ); + if( poJ2KDataset == NULL ) + return NULL; + + delete poJ2KDataset; + + // Now we need to figure out the actual length of the file + // and correct the image segment size information. + GIntBig nPixelCount = nXSize * ((GIntBig) nYSize) * + poSrcDS->GetRasterCount(); + + NITFPatchImageLength( pszFilename, nImageOffset, nPixelCount ); + + poDstDS = (NITFDataset *) GDALOpen( pszFilename, GA_Update ); + + if( poDstDS == NULL ) + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Set the georeferencing. */ +/* -------------------------------------------------------------------- */ + if( bWriteGeoTransform ) + { + poDstDS->psImage->nZone = nZone; + poDstDS->SetGeoTransform( adfGeoTransform ); + } + + poDstDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT ); + + return poDstDS; +} + +/************************************************************************/ +/* NITFPatchImageLength() */ +/* */ +/* Fixup various stuff we don't know till we have written the */ +/* imagery. In particular the file length, image data length */ +/* and the compression ratio achieved. */ +/************************************************************************/ + +static void NITFPatchImageLength( const char *pszFilename, + long nImageOffset, + GIntBig nPixelCount ) + +{ + FILE *fpVSIL = VSIFOpenL( pszFilename, "r+b" ); + if( fpVSIL == NULL ) + return; + + VSIFSeekL( fpVSIL, 0, SEEK_END ); + GIntBig nFileLen = VSIFTellL( fpVSIL ); + +/* -------------------------------------------------------------------- */ +/* Update total file length. */ +/* -------------------------------------------------------------------- */ + VSIFSeekL( fpVSIL, 342, SEEK_SET ); + VSIFWriteL( (void *) CPLSPrintf("%012d",nFileLen), + 1, 12, fpVSIL ); + +/* -------------------------------------------------------------------- */ +/* Update the image data length. */ +/* -------------------------------------------------------------------- */ + VSIFSeekL( fpVSIL, 369, SEEK_SET ); + VSIFWriteL( (void *) CPLSPrintf("%010d",nFileLen-nImageOffset), + 1, 10, fpVSIL ); + +/* -------------------------------------------------------------------- */ +/* Update COMRAT, the compression rate variable. It is a bit */ +/* hard to know right here whether we have an IGEOLO segment, */ +/* so the COMRAT will either be at offset 778 or 838. */ +/* -------------------------------------------------------------------- */ + char szIC[2]; + VSIFSeekL( fpVSIL, 779-2, SEEK_SET ); + VSIFReadL( szIC, 2, 1, fpVSIL ); + if( szIC[0] != 'C' && szIC[1] != '8' ) + { + VSIFSeekL( fpVSIL, 839-2, SEEK_SET ); + VSIFReadL( szIC, 2, 1, fpVSIL ); + } + + if( szIC[0] != 'C' && szIC[1] != '8' ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Unable to locate COMRAT to update in NITF header." ); + } + else + { + char szCOMRAT[5]; + + double dfRate = (nFileLen-nImageOffset) * 8 / (double) nPixelCount; + dfRate = MAX(0.01,MIN(99.99,dfRate)); + + // We emit in wxyz format with an implicit decimal place + // between wx and yz as per spec for lossy compression. + // We really should have a special case for lossless compression. + sprintf( szCOMRAT, "%04d", (int) (dfRate * 100)); + VSIFWriteL( szCOMRAT, 4, 1, fpVSIL ); + } + + VSIFCloseL( fpVSIL ); +} + +/************************************************************************/ +/* GDALRegister_NITF() */ +/************************************************************************/ + +void GDALRegister_NITF() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "NITF" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "NITF" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "National Imagery Transmission Format" ); + + poDriver->pfnOpen = NITFDataset::Open; + poDriver->pfnCreate = NITFDatasetCreate; + poDriver->pfnCreateCopy = NITFDataset::NITFCreateCopy; + + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, "frmt_nitf.html" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "ntf" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte UInt16 Int16 UInt32 Int32 Float32" ); + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/nitf/nitfdump.c b/Utilities/GDAL/frmts/nitf/nitfdump.c new file mode 100644 index 0000000000000000000000000000000000000000..6466a8897a8f02841497180f75c0c0c587e68cb3 --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/nitfdump.c @@ -0,0 +1,362 @@ +/****************************************************************************** + * $Id$ + * + * Project: NITF Read/Write Library + * Purpose: Simple test mainline to dump info about NITF file. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ********************************************************************** + * Copyright (c) 2002, Frank Warmerdam + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ****************************************************************************** + * + * $Log: nitfdump.c,v $ + * Revision 1.7 2004/05/06 14:58:06 warmerda + * added USE00A and STDIDC parsing and reporting as metadata + * + * Revision 1.6 2003/05/29 19:50:10 warmerda + * added RPC (and more general TRE) reporting + * + * Revision 1.5 2002/12/18 21:18:38 warmerda + * report corners more sensibly + * + * Revision 1.4 2002/12/17 05:26:26 warmerda + * implement basic write support + * + * Revision 1.3 2002/12/03 18:07:40 warmerda + * added VQLUT reporting + * + * Revision 1.2 2002/12/03 04:43:54 warmerda + * lots of work + * + * Revision 1.1 2002/12/02 06:09:29 warmerda + * New + * + */ + +#include "nitflib.h" +#include "cpl_string.h" + +CPL_CVSID("$Id$"); + +static void DumpRPC( NITFImage *psImage, NITFRPC00BInfo *psRPC ); +static void DumpMetadata( const char *, const char *, char ** ); + +/************************************************************************/ +/* main() */ +/************************************************************************/ + +int main( int nArgc, char ** papszArgv ) + +{ + NITFFile *psFile; + int iSegment; + char szTemp[100]; + + if( nArgc < 2 ) + { + printf( "Usage: nitfdump <nitf_filename>\n" ); + exit( 1 ); + } + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + psFile = NITFOpen( papszArgv[1], FALSE ); + if( psFile == NULL ) + exit( 2 ); + +/* -------------------------------------------------------------------- */ +/* Dump first TRE list. */ +/* -------------------------------------------------------------------- */ + if( psFile->pachTRE != NULL ) + { + int nTREBytes = psFile->nTREBytes; + const char *pszTREData = psFile->pachTRE; + + + printf( "File TREs:" ); + + while( nTREBytes > 10 ) + { + int nThisTRESize = atoi(NITFGetField(szTemp, pszTREData, 6, 5 )); + + printf( " %6.6s(%d)", pszTREData, nThisTRESize ); + pszTREData += nThisTRESize + 11; + nTREBytes -= (nThisTRESize + 11); + } + printf( "\n" ); + } + +/* -------------------------------------------------------------------- */ +/* Report info from location table, if found. */ +/* -------------------------------------------------------------------- */ + if( psFile->nLocCount > 0 ) + { + int i; + printf( "Location Table\n" ); + for( i = 0; i < psFile->nLocCount; i++ ) + { + printf( " LocId=%d, Offset=%d, Size=%d\n", + psFile->pasLocations[i].nLocId, + psFile->pasLocations[i].nLocOffset, + psFile->pasLocations[i].nLocSize ); + } + printf( "\n" ); + } + +/* -------------------------------------------------------------------- */ +/* Dump Metadata */ +/* -------------------------------------------------------------------- */ + DumpMetadata( "File Metadata:", " ", psFile->papszMetadata ); + +/* -------------------------------------------------------------------- */ +/* Dump general info about segments. */ +/* -------------------------------------------------------------------- */ + for( iSegment = 0; iSegment < psFile->nSegmentCount; iSegment++ ) + { + NITFSegmentInfo *psSegInfo = psFile->pasSegmentInfo + iSegment; + + printf( "Segment %d (Type=%s):\n", + iSegment + 1, psSegInfo->szSegmentType ); + + printf( " HeaderStart=%d, HeaderSize=%d, DataStart=%d, DataSize=%d\n", + psSegInfo->nSegmentHeaderStart, + psSegInfo->nSegmentHeaderSize, + psSegInfo->nSegmentStart, + psSegInfo->nSegmentSize ); + printf( "\n" ); + } + +/* -------------------------------------------------------------------- */ +/* Report details of images. */ +/* -------------------------------------------------------------------- */ + for( iSegment = 0; iSegment < psFile->nSegmentCount; iSegment++ ) + { + NITFSegmentInfo *psSegInfo = psFile->pasSegmentInfo + iSegment; + NITFImage *psImage; + NITFRPC00BInfo sRPCInfo; + int iBand; + char **papszMD; + + if( !EQUAL(psSegInfo->szSegmentType,"IM") ) + continue; + + psImage = NITFImageAccess( psFile, iSegment ); + if( psImage == NULL ) + { + printf( "NITFAccessImage(%d) failed!\n", iSegment ); + continue; + } + + printf( "Image Segment %d, %dPx%dLx%dB x %dbits:\n", + iSegment, psImage->nRows, psImage->nCols, psImage->nBands, + psImage->nBitsPerSample ); + printf( " PVTYPE=%s, IREP=%s, ICAT=%s, IMODE=%c, IC=%s, COMRAT=%s, ICORDS=%c\n", + psImage->szPVType, psImage->szIREP, psImage->szICAT, + psImage->chIMODE, psImage->szIC, psImage->szCOMRAT, + psImage->chICORDS ); + if( psImage->chICORDS != ' ' ) + { + printf( " UL=(%g,%g), UR=(%g,%g)\n LL=(%g,%g), LR=(%g,%g)\n", + psImage->dfULX, psImage->dfULY, + psImage->dfURX, psImage->dfURY, + psImage->dfLLX, psImage->dfLLY, + psImage->dfLRX, psImage->dfLRY ); + } + + printf( " %d x %d blocks of size %d x %d\n", + psImage->nBlocksPerRow, psImage->nBlocksPerColumn, + psImage->nBlockWidth, psImage->nBlockHeight ); + + if( psImage->pachTRE != NULL ) + { + int nTREBytes = psImage->nTREBytes; + const char *pszTREData = psImage->pachTRE; + + + printf( " Image TREs:" ); + + while( nTREBytes > 10 ) + { + int nThisTRESize = atoi(NITFGetField(szTemp, pszTREData, 6, 5 )); + + printf( " %6.6s(%d)", pszTREData, nThisTRESize ); + pszTREData += nThisTRESize + 11; + nTREBytes -= (nThisTRESize + 11); + } + printf( "\n" ); + } + + if( strlen(psImage->pszComments) > 0 ) + printf( " Comments:\n%s\n", psImage->pszComments ); + + for( iBand = 0; iBand < psImage->nBands; iBand++ ) + { + NITFBandInfo *psBandInfo = psImage->pasBandInfo + iBand; + + printf( " Band %d: IREPBAND=%s, ISUBCAT=%s, %d LUT entries.\n", + iBand + 1, psBandInfo->szIREPBAND, psBandInfo->szISUBCAT, + psBandInfo->nSignificantLUTEntries ); + } + + if( NITFReadRPC00B( psImage, &sRPCInfo ) ) + { + DumpRPC( psImage, &sRPCInfo ); + } + + papszMD = NITFReadUSE00A( psImage ); + if( papszMD != NULL ) + { + DumpMetadata( " USE00A TRE:", " ", papszMD ); + CSLDestroy( papszMD ); + } + + papszMD = NITFReadSTDIDC( psImage ); + if( papszMD != NULL ) + { + DumpMetadata( " STDIDC TRE:", " ", papszMD ); + CSLDestroy( papszMD ); + } + + DumpMetadata( " Image Metadata:", " ", psImage->papszMetadata ); + } + +/* -------------------------------------------------------------------- */ +/* Close. */ +/* -------------------------------------------------------------------- */ + NITFClose( psFile ); + + exit( 0 ); +} + +/************************************************************************/ +/* DumpMetadata() */ +/************************************************************************/ + +static void DumpMetadata( const char *pszTitle, const char *pszPrefix, + char ** papszMD ) +{ + int i; + + if( papszMD == NULL ) + return; + + printf( "%s\n", pszTitle ); + + for( i = 0; papszMD[i] != NULL; i++ ) + printf( "%s%s\n", pszPrefix, papszMD[i] ); +} + +/************************************************************************/ +/* DumpRPC() */ +/************************************************************************/ + +static void DumpRPC( NITFImage *psImage, NITFRPC00BInfo *psRPC ) + +{ + int i; + + printf( " RPC00B:\n" ); + printf( " SUCCESS=%d\n", psRPC->SUCCESS ); + printf( " ERR_BIAS=%.16g\n", psRPC->ERR_BIAS ); + printf( " ERR_RAND=%.16g\n", psRPC->ERR_RAND ); + + printf( " LINE_OFF=%.16g\n", psRPC->LINE_OFF ); + printf( " SAMP_OFF=%.16g\n", psRPC->SAMP_OFF ); + printf( " LAT_OFF =%.16g\n", psRPC->LAT_OFF ); + printf( " LONG_OFF=%.16g\n", psRPC->LONG_OFF ); + printf( " HEIGHT_OFF=%.16g\n", psRPC->HEIGHT_OFF ); + + printf( " LINE_SCALE=%.16g\n", psRPC->LINE_SCALE ); + printf( " SAMP_SCALE=%.16g\n", psRPC->SAMP_SCALE ); + printf( " LAT_SCALE =%.16g\n", psRPC->LAT_SCALE ); + printf( " LONG_SCALE=%.16g\n", psRPC->LONG_SCALE ); + printf( " HEIGHT_SCALE=%.16g\n", psRPC->HEIGHT_SCALE ); + + printf( " LINE_NUM_COEFF = " ); + for( i=0; i < 20; i++ ) + { + printf( "%.12g ", psRPC->LINE_NUM_COEFF[i] ); + + if( i == 19 ) + printf( "\n" ); + else if( (i%5) == 4 ) + printf( "\n " ); + } + + printf( " LINE_DEN_COEFF = " ); + for( i=0; i < 20; i++ ) + { + printf( "%.12g ", psRPC->LINE_DEN_COEFF[i] ); + + if( i == 19 ) + printf( "\n" ); + else if( (i%5) == 4 ) + printf( "\n " ); + } + + printf( " SAMP_NUM_COEFF = " ); + for( i=0; i < 20; i++ ) + { + printf( "%.12g ", psRPC->SAMP_NUM_COEFF[i] ); + + if( i == 19 ) + printf( "\n" ); + else if( (i%5) == 4 ) + printf( "\n " ); + } + + printf( " SAMP_DEN_COEFF = " ); + for( i=0; i < 20; i++ ) + { + printf( "%.12g ", psRPC->SAMP_DEN_COEFF[i] ); + + if( i == 19 ) + printf( "\n" ); + else if( (i%5) == 4 ) + printf( "\n " ); + } + +/* -------------------------------------------------------------------- */ +/* Dump some known locations. */ +/* -------------------------------------------------------------------- */ + { + double adfLong[] = { psImage->dfULX, psImage->dfURX, + psImage->dfLLX, psImage->dfLRX, + (psImage->dfULX + psImage->dfLRX) / 2, + (psImage->dfULX + psImage->dfLRX) / 2 }; + double adfLat[] = { psImage->dfULY, psImage->dfURY, + psImage->dfLLY, psImage->dfLRY, + (psImage->dfULY + psImage->dfLRY) / 2, + (psImage->dfULY + psImage->dfLRY) / 2 }; + double adfHeight[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 300.0 }; + double dfPixel, dfLine; + + for( i = 0; i < sizeof(adfLong) / sizeof(double); i++ ) + { + NITFRPCGeoToImage( psRPC, adfLong[i], adfLat[i], adfHeight[i], + &dfPixel, &dfLine ); + + printf( " RPC Transform (%.12g,%.12g,%g) -> (%g,%g)\n", + adfLong[i], adfLat[i], adfHeight[i], dfPixel, dfLine ); + } + } +} diff --git a/Utilities/GDAL/frmts/nitf/nitflib.h b/Utilities/GDAL/frmts/nitf/nitflib.h new file mode 100644 index 0000000000000000000000000000000000000000..c10c28dd429eb5e67de00b819e3ce0df66e2ae8e --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/nitflib.h @@ -0,0 +1,367 @@ +/****************************************************************************** + * $Id$ + * + * Project: NITF Read/Write Library + * Purpose: Main GDAL independent include file for NITF support. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ********************************************************************** + * Copyright (c) 2002, Frank Warmerdam + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ****************************************************************************** + * + * $Log: nitflib.h,v $ + * Revision 1.17 2005/02/18 19:28:15 fwarmerdam + * added NITFIHFieldOffset + * + * Revision 1.16 2004/12/21 04:57:36 fwarmerdam + * added support for writing UTM ICORDS/IGEOLO values + * + * Revision 1.15 2004/12/10 21:35:00 fwarmerdam + * preliminary support for writing JPEG2000 compressed data + * + * Revision 1.14 2004/12/10 21:27:24 fwarmerdam + * Added ICHIPB support + * + * Revision 1.13 2004/05/06 14:58:06 warmerda + * added USE00A and STDIDC parsing and reporting as metadata + * + * Revision 1.12 2004/04/28 15:19:00 warmerda + * added geocentric to geodetic conversion + * + * Revision 1.11 2004/04/16 15:26:04 warmerda + * completed metadata support + * + * Revision 1.10 2004/04/15 20:52:53 warmerda + * added metadata support + * + * Revision 1.9 2004/04/02 20:44:37 warmerda + * preserve APBB (actual bits per pixel) field as metadata + * + * Revision 1.8 2003/05/29 19:50:57 warmerda + * added TRE in image, and RPC00B support + * + * Revision 1.7 2002/12/18 20:16:04 warmerda + * support writing IGEOLO + * + * Revision 1.6 2002/12/18 06:35:15 warmerda + * implement nodata support for mapped data + * + * Revision 1.5 2002/12/17 21:23:15 warmerda + * implement LUT reading and writing + * + * Revision 1.4 2002/12/17 20:03:08 warmerda + * added rudimentary NITF 1.1 support + * + * Revision 1.3 2002/12/17 05:26:26 warmerda + * implement basic write support + * + * Revision 1.2 2002/12/03 04:43:54 warmerda + * lots of work + * + * Revision 1.1 2002/12/02 06:09:29 warmerda + * New + * + */ + +#ifndef NITFLIB_H_INCLUDED +#define NITFLIB_H_INCLUDED + +#include "cpl_port.h" +#include "cpl_error.h" + +CPL_C_START + +typedef struct { + char szSegmentType[3]; /* one of "IM", ... */ + + GUInt32 nSegmentHeaderStart; + GUInt32 nSegmentHeaderSize; + GUInt32 nSegmentStart; + GUInt32 nSegmentSize; + + void *hAccess; +} NITFSegmentInfo; + +typedef struct { + int nLocId; + int nLocOffset; + int nLocSize; +} NITFLocation; + + +typedef struct { + FILE *fp; + + char szVersion[10]; + + int nSegmentCount; + NITFSegmentInfo *pasSegmentInfo; + + char *pachHeader; + + int nTREBytes; + char *pachTRE; + + GUInt32 *apanVQLUT[4]; + + int nLocCount; + NITFLocation *pasLocations; + + char **papszMetadata; + +} NITFFile; + +/* -------------------------------------------------------------------- */ +/* File level prototypes. */ +/* -------------------------------------------------------------------- */ +NITFFile CPL_DLL *NITFOpen( const char *pszFilename, int bUpdatable ); +void CPL_DLL NITFClose( NITFFile * ); + +int CPL_DLL NITFCreate( const char *pszFilename, + int nPixels, int nLines, int nBands, + int nBitsPerSample, const char *pszPVType, + char **papszOptions ); + +const char CPL_DLL *NITFFindTRE( const char *pszTREData, int nTREBytes, + const char *pszTag, int *pnFoundTRESize ); + +/* -------------------------------------------------------------------- */ +/* Image level access. */ +/* -------------------------------------------------------------------- */ +typedef struct { + char szIREPBAND[3]; + char szISUBCAT[7]; + + int nSignificantLUTEntries; + int nLUTLocation; + unsigned char *pabyLUT; + +} NITFBandInfo; + +typedef struct { + NITFFile *psFile; + int iSegment; + char *pachHeader; + + int nRows; + int nCols; + int nBands; + int nBitsPerSample; + + NITFBandInfo *pasBandInfo; + + char chIMODE; + + int nBlocksPerRow; + int nBlocksPerColumn; + int nBlockWidth; + int nBlockHeight; + + char szPVType[4]; + char szIREP[9]; + char szICAT[9]; + int nABPP; /* signficant bits per pixel */ + + char chICORDS; + int bHaveIGEOLO; + + int nZone; + double dfULX; + double dfULY; + double dfURX; + double dfURY; + double dfLRX; + double dfLRY; + double dfLLX; + double dfLLY; + + char *pszComments; + char szIC[3]; + char szCOMRAT[5]; + + int bNoDataSet; + int nNoDataValue; + + int nTREBytes; + char *pachTRE; + + /* Internal information not for application use. */ + + int nWordSize; + int nPixelOffset; + int nLineOffset; + int nBlockOffset; + int nBandOffset; + + GUInt32 *panBlockStart; + + char **papszMetadata; + +} NITFImage; + +NITFImage CPL_DLL *NITFImageAccess( NITFFile *, int iSegment ); +void CPL_DLL NITFImageDeaccess( NITFImage * ); + +int CPL_DLL NITFReadImageBlock( NITFImage *, int nBlockX, int nBlockY, + int nBand, void *pData ); +int CPL_DLL NITFReadImageLine( NITFImage *, int nLine, int nBand, + void *pData ); +int CPL_DLL NITFWriteImageBlock( NITFImage *, int nBlockX, int nBlockY, + int nBand, void *pData ); +int CPL_DLL NITFWriteImageLine( NITFImage *, int nLine, int nBand, + void *pData ); +int CPL_DLL NITFWriteLUT( NITFImage *psImage, int nBand, int nColors, + unsigned char *pabyLUT ); +int CPL_DLL NITFWriteIGEOLO( NITFImage *psImage, char chICORDS, + int nZone, + double dfULX, double dfULY, + double dfURX, double dfURY, + double dfLRX, double dfLRY, + double dfLLX, double dfLLY ); +char CPL_DLL **NITFReadUSE00A( NITFImage *psImage ); +char CPL_DLL **NITFReadSTDIDC( NITFImage *psImage ); + +GUInt32 CPL_DLL NITFIHFieldOffset( NITFImage *psImage, + const char *pszFieldName ); + +#define BLKREAD_OK 0 +#define BLKREAD_NULL 1 +#define BLKREAD_FAIL 2 + +/* -------------------------------------------------------------------- */ +/* These are really intended to be private helper stuff for the */ +/* library. */ +/* -------------------------------------------------------------------- */ +char *NITFGetField( char *pszTarget, const char *pszSource, + int nStart, int nLength ); +void NITFExtractMetadata( char ***ppapszMetadata, const char *pachHeader, + int nStart, int nLength, const char *pszName ); + +/* -------------------------------------------------------------------- */ +/* location ids from the location table (from MIL-STD-2411-1). */ +/* -------------------------------------------------------------------- */ + +typedef enum { + LID_HeaderComponent = 128, + LID_LocationComponent = 129, + LID_CoverageSectionSubheader = 130, + LID_CompressionSectionSubsection = 131, + LID_CompressionLookupSubsection = 132, + LID_CompressionParameterSubsection = 133, + LID_ColorGrayscaleSectionSubheader = 134, + LID_ColormapSubsection = 135, + LID_ImageDescriptionSubheader = 136, + LID_ImageDisplayParametersSubheader = 137, + LID_MaskSubsection = 138, + LID_ColorConverterSubsection = 139, + LID_SpatialDataSubsection = 140, + LID_AttributeSectionSubheader = 141, + LID_AttributeSubsection = 142, + LID_ExplicitArealCoverageTable = 143, + LID_RelatedImagesSectionSubheader = 144, + LID_RelatedImagesSubsection = 145, + LID_ReplaceUpdateSectionSubheader = 146, + LID_ReplaceUpdateTable = 147, + LID_BoundaryRectangleSectionSubheader = 148, + LID_BoundaryRectangleTable = 149, + LID_FrameFileIndexSectionSubHeader = 150, + LID_FrameFileIndexSubsection = 151, + LID_ColorTableIndexSectionSubheader = 152, + LID_ColorTableIndexRecord = 153 +} NITFLocId; + +/* -------------------------------------------------------------------- */ +/* RPC structure, and function to fill it. */ +/* -------------------------------------------------------------------- */ +typedef struct { + int SUCCESS; + + double ERR_BIAS; + double ERR_RAND; + + double LINE_OFF; + double SAMP_OFF; + double LAT_OFF; + double LONG_OFF; + double HEIGHT_OFF; + + double LINE_SCALE; + double SAMP_SCALE; + double LAT_SCALE; + double LONG_SCALE; + double HEIGHT_SCALE; + + double LINE_NUM_COEFF[20]; + double LINE_DEN_COEFF[20]; + double SAMP_NUM_COEFF[20]; + double SAMP_DEN_COEFF[20]; +} NITFRPC00BInfo; + +int CPL_DLL NITFReadRPC00B( NITFImage *psImage, NITFRPC00BInfo * ); +int CPL_DLL NITFRPCGeoToImage(NITFRPC00BInfo *, double, double, double, + double *, double *); + +/* -------------------------------------------------------------------- */ +/* ICHIP structure, and function to fill it. */ +/* -------------------------------------------------------------------- */ +typedef struct { + int XFRM_FLAG; + double SCALE_FACTOR; + int ANAMORPH_CORR; + int SCANBLK_NUM; + + double OP_ROW_11; + double OP_COL_11; + + double OP_ROW_12; + double OP_COL_12; + + double OP_ROW_21; + double OP_COL_21; + + double OP_ROW_22; + double OP_COL_22; + + double FI_ROW_11; + double FI_COL_11; + + double FI_ROW_12; + double FI_COL_12; + + double FI_ROW_21; + double FI_COL_21; + + double FI_ROW_22; + double FI_COL_22; + + int FI_ROW; + int FI_COL; +} NITFICHIPBInfo; + +int CPL_DLL NITFReadICHIPB( NITFImage *psImage, NITFICHIPBInfo * ); + +double CPL_DLL + NITF_WGS84_Geocentric_Latitude_To_Geodetic_Latitude( double dfLat ); + +CPL_C_END + +#endif /* ndef NITFLIB_H_INCLUDED */ + diff --git a/Utilities/GDAL/frmts/ogdi/GNUmakefile b/Utilities/GDAL/frmts/ogdi/GNUmakefile deleted file mode 100644 index caf0e895e5c2ac3df1d966fa1932953f6d2be3bb..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/ogdi/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = ogdidataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(OGDI_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/pcidsk/GNUmakefile b/Utilities/GDAL/frmts/pcidsk/GNUmakefile deleted file mode 100644 index 3a78640b5ca2475a85065d8b88692fa748f4baeb..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/pcidsk/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = pcidskdataset.o pcidsktiledrasterband.o - -CPPFLAGS := $(GDAL_INCLUDE) -I../raw $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/pcraster/GNUmakefile b/Utilities/GDAL/frmts/pcraster/GNUmakefile deleted file mode 100644 index 458077bdac0c5a067a581fb5f2417805354fb274..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/pcraster/GNUmakefile +++ /dev/null @@ -1,28 +0,0 @@ - -include ../../GDALmake.opt - -CPPFLAGS := $(XTRA_OPT) $(GDAL_INCLUDE) $(CPPFLAGS) - -ifeq ($(PCRASTER_SETTING),internal) -CPPFLAGS += -DUSE_IN_GDAL -Ilibcsf -OBJ = _getcell.o _getrow.o _gsomece.o _putcell.o _rputrow.o angle.o attravai.o attrsize.o cellsize.o create2.o csfglob.o csfsup.o delattr.o dumconv.o endian.o filename.o gattrblk.o gattridx.o gcellrep.o gdattype.o getattr.o getx0.o gety0.o ggisfid.o gmaxval.o gminval.o gnrcols.o gnrrows.o gproj.o gputproj.o gvalscal.o gvartype.o gversion.o ismv.o kernlcsf.o legend.o mclose.o mopen.o moreattr.o mperror.o pgisfid.o pmaxval.o pminval.o putallmv.o putattr.o putsomec.o putx0.o puty0.o pvalscal.o rattrblk.o rcomp.o rcoords.o rdup2.o reseterr.o rextend.o rmalloc.o rrowcol.o ruseas.o setangle.o setmv.o setvtmv.o strconst.o strpad.o swapio.o trackmm.o vs2.o vsdef.o vsis.o vsvers.o wattrblk.o -endif - -OBJ += pcrasterdataset.o pcrastermisc.o pcrasterrasterband.o pcrasterutil.o - -default: $(OBJ) - -clean: - rm -f *.o libcsf/*.o $(O_OBJ) - rm -fR html - -../o/%.o: libcsf/%.c - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ - -install-obj: $(O_OBJ) - -docs: - doxygen doxygen.cfg - -ctags: - ctags *cpp *h diff --git a/Utilities/GDAL/frmts/png/GNUmakefile b/Utilities/GDAL/frmts/png/GNUmakefile deleted file mode 100644 index f25feead6d111a08f403adef2287ae47e558c04e..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/png/GNUmakefile +++ /dev/null @@ -1,30 +0,0 @@ - -include ../../GDALmake.opt - -ifeq ($(PNG_SETTING),internal) -XTRA_OPT = -DPNG_NO_GLOBAL_ARRAYS -Ilibpng -OBJ = png.o pngerror.o pnggccrd.o pngget.o pngmem.o \ - pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o \ - pngset.o pngtrans.o pngvcrd.o pngwio.o pngwrite.o \ - pngwtran.o pngwutil.o \ - \ - pngdataset.o -else -OBJ = pngdataset.o -endif - -XTRA_OPT := $(XTRA_OPT) -I../zlib - -CPPFLAGS := $(XTRA_OPT) $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o libpng/*.o $(O_OBJ) - -../o/%.o: libpng/%.c - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ - -all: $(OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/rik/GNUmakefile b/Utilities/GDAL/frmts/rik/GNUmakefile deleted file mode 100644 index 4feabca28ecef79fbab27d9333d223ca438150d4..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/rik/GNUmakefile +++ /dev/null @@ -1,19 +0,0 @@ - -include ../../GDALmake.opt - -ifeq ($(LIBZ_SETTING),internal) -XTRA_OPT = -I../zlib -else -XTRA_OPT = -endif - -OBJ = rikdataset.o - -CPPFLAGS := $(XTRA_OPT) $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/rmf/GNUmakefile b/Utilities/GDAL/frmts/rmf/GNUmakefile deleted file mode 100644 index 03c2ce1c46614c7fa58fb3be3d09fe10593fa02e..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/rmf/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = rmfdataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/rs2/GNUmakefile b/Utilities/GDAL/frmts/rs2/GNUmakefile deleted file mode 100644 index 3833142d624e87abd2f4661dede614fa27323644..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/rs2/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = rs2dataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/sgi/GNUmakefile b/Utilities/GDAL/frmts/sgi/GNUmakefile deleted file mode 100644 index c5c189ada21010d6f2e12ceef7f1baf81ab12572..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/sgi/GNUmakefile +++ /dev/null @@ -1,18 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = sgidataset.o - -CPPFLAGS := $(XTRA_OPT) $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -../o/%.o: - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ - -all: $(OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/terragen/GNUmakefile b/Utilities/GDAL/frmts/terragen/GNUmakefile deleted file mode 100644 index c86bfad7c513d3f9d83d3a3ce6e7a23816117aa7..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/terragen/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ - -include ../../GDALmake.opt - -OBJ = terragendataset.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/vrt/GNUmakefile b/Utilities/GDAL/frmts/vrt/GNUmakefile deleted file mode 100644 index 6424adb21faf2b16b378aa86c5d923605fe9fd4d..0000000000000000000000000000000000000000 --- a/Utilities/GDAL/frmts/vrt/GNUmakefile +++ /dev/null @@ -1,21 +0,0 @@ - - -include ../../GDALmake.opt - -OBJ = vrtdataset.o vrtrasterband.o vrtdriver.o vrtsources.o \ - vrtfilters.o vrtsourcedrasterband.o vrtrawrasterband.o \ - vrtwarped.o vrtderivedrasterband.o - -CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) -I../raw - -default: $(OBJ) - -clean: - rm -f *.o $(O_OBJ) - -install-obj: $(O_OBJ) - -$(OBJ) $(O_OBJ): vrtdataset.h - -install: - $(INSTALL_DATA) vrtdataset.h $(INST_INCLUDE)